public Task <int> SubmitForm <TDto>(WaterMDisinfectEntity entity, TDto dto) where TDto : class { if (!string.IsNullOrEmpty(entity.F_Id)) { entity.Modify(entity.F_Id); return(_service.UpdateAsync(entity, dto)); } else { entity.Create(); return(_service.InsertAsync(entity)); } }
public IActionResult SubmitData([FromBody] SubmitDataInput input) { var userId = _usersService.GetCurrentUserId(); WaterMDisinfectEntity entity = null; if (string.IsNullOrEmpty(input.id))//新建 { entity = new WaterMDisinfectEntity { F_Id = Common.GuId(), F_OperatePerson = userId, F_CreatorTime = DateTime.Now, F_CreatorUserId = userId, F_EnabledMark = true }; } else//修改 { entity = new WaterMDisinfectEntity { F_Id = input.id, F_LastModifyTime = DateTime.Now, F_LastModifyUserId = userId }; } entity.F_DisinfectDate = input.disinfectDate; entity.F_DisinfectantName = input.disinfectantName; entity.F_DisinfectantVolume = input.disinfectantVolume; entity.F_DisinfectantUnit = input.disinfectantUnit; entity.F_DisinfectType = input.disinfectType; entity.F_Option1 = input.option1; entity.F_Option2 = input.option2; entity.F_Option3 = input.option3; entity.F_RecyclingStartTime = input.recyclingStartTime; entity.F_RecyclingEndTime = input.recyclingEndTime; entity.F_SoakStartTime = input.soakStartTime; entity.F_SoakEndTime = input.soakEndTime; entity.F_RinseStartTime = input.rinseStartTime; entity.F_RinseEndTime = input.rinseEndTime; if (input.recyclingMinutes == null) { if (input.recyclingStartTime != null && input.recyclingEndTime != null) { entity.F_RecyclingMinutes = (input.recyclingEndTime.ToDate() - input.recyclingStartTime.ToDate()).TotalMinutes.ToFloat(1); } } else { entity.F_RecyclingMinutes = input.recyclingMinutes; } if (input.soakMinutes == null) { if (input.soakStartTime != null && input.soakEndTime != null) { entity.F_SoakMinutes = (input.soakEndTime.ToDate() - input.soakStartTime.ToDate()).TotalMinutes.ToFloat(1); } } else { entity.F_SoakMinutes = input.soakMinutes; } if (input.rinseMinutes == null) { if (input.rinseEndTime != null && input.rinseStartTime != null) { entity.F_RinseMinutes = (input.rinseEndTime.ToDate() - input.rinseStartTime.ToDate()).TotalMinutes.ToFloat(1); } } else { entity.F_RinseMinutes = input.rinseMinutes; } if (string.IsNullOrEmpty(input.id)) { _waterMDisinfectApp.InsertForm(entity); } else { _waterMDisinfectApp.UpdateForm(entity); } var data = new { id = entity.F_Id }; return(Ok(data)); }
public Task <int> InsertForm(WaterMDisinfectEntity entity) { return(_service.InsertAsync(entity)); }
public Task <int> UpdateForm(WaterMDisinfectEntity entity) { return(_service.UpdatePartialAsync(entity)); }