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; }
public static HealthyEntity ConvertToHealthy(SickEntity entity) { var healthy = new HealthyEntity(); healthy.direction = entity.direction; healthy.age = entity.age; return(healthy); }
public static SickEntity ConvertToSick(HealthyEntity entity) { var sick = new SickEntity(); sick.direction = entity.direction; sick.age = entity.age; return(sick); }
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); }
public async Task<BaseResult<SickEntity>> Add(SickEntity entity) { return await sickRepository.Add(entity); }