//--------------------------------------------------------------------
//     此代码由T4模板自动生成  byzhouhang 20210918
//	   生成时间 2022-07-01 15:37:24 
//     对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
//--------------------------------------------------------------------
using IRaCIS.Core.Domain.Models;
using Microsoft.AspNetCore.Mvc;
using IRaCIS.Core.Application.Interfaces;
using IRaCIS.Core.Application.ViewModel;
namespace IRaCIS.Core.Application.Service
{	
	/// 
	/// TaskConsistentRuleService
	/// 	
	[ ApiExplorerSettings(GroupName = "Test")]
	public class TaskConsistentRuleService: BaseService, ITaskConsistentRuleService
    {
			 private readonly IRepository _taskConsistentRuleRepository;
		public TaskConsistentRuleService(IRepository taskConsistentRuleRepository)
		{
            _taskConsistentRuleRepository = taskConsistentRuleRepository;        
		}
	   
		public async Task>  GetTaskConsistentRuleList(TaskConsistentRuleQuery inQuery)
		{
		
		     var taskConsistentRuleQueryable = _taskConsistentRuleRepository
			 .ProjectTo(_mapper.ConfigurationProvider);
             
			 return await taskConsistentRuleQueryable.ToListAsync();
		}
	    
        public async  Task AddOrUpdateTaskConsistentRule(TaskConsistentRuleAddOrEdit addOrEditTaskConsistentRule)
		{
		      //  在此处拷贝automapper 映射
			  
                 CreateMap();
			  //  CreateMap< TaskConsistentRule,TaskConsistentRuleAddOrEdit>().ReverseMap();
			    var entity = await _taskConsistentRuleRepository.InsertOrUpdateAsync(addOrEditTaskConsistentRule, true);
            return ResponseOutput.Ok(entity.Id.ToString());
		
		}
		[HttpDelete("{taskConsistentRuleId:guid}")]
        public async Task DeleteTaskConsistentRule(Guid taskConsistentRuleId)
		{
			  var success = await _taskConsistentRuleRepository.DeleteFromQueryAsync(t => t.Id == taskConsistentRuleId,true);
              return ResponseOutput.Ok();
		}
       
    }
}