コード例 #1
0
 public async Task<BaseResult<SickEntity>> DeleteList([FromBody]DeleteDTO model)
 {
     if (model.ids.Count == 0)
     {
         throw new Exception("参数接受失败");
     }
     var idList = model.ids;
     foreach (int item in idList)
     {
         var number = await sickRepository.Detail(item);
         if (number.code != "0")
         {
             throw new Exception("数据不存在");
         }
         SickEntity entity = new SickEntity()
         {
             id = item
         };
         try
         {
             await sickRepository.Delete(entity);
         }
         catch (Exception e)
         {
             throw new Exception(e.Message);
         }
     }
     var result = new BaseResult<SickEntity>()
     {
         code = "0",
         data = null,
         desc = "删除成功",
     };
     return result;
 }
コード例 #2
0
        public static HealthyEntity ConvertToHealthy(SickEntity entity)
        {
            var healthy = new HealthyEntity();

            healthy.direction = entity.direction;
            healthy.age       = entity.age;
            return(healthy);
        }
コード例 #3
0
        public static SickEntity ConvertToSick(HealthyEntity entity)
        {
            var sick = new SickEntity();

            sick.direction = entity.direction;
            sick.age       = entity.age;
            return(sick);
        }
コード例 #4
0
 public async Task<BaseResult<SickEntity>> Updata(SickEntity entity)
 {
     var number = await sickRepository.Detail(entity.id);
     var result = new BaseResult<SickEntity>();
     if (number.code != "0")
     {
         throw new Exception("数据不存在");
     }
     return await sickRepository.Updata(entity);
 }
コード例 #5
0
 public async Task<BaseResult<SickEntity>> Add(SickEntity entity)
 {
     return await sickRepository.Add(entity);
 }