public IActionResult InfoEdit(DecompInfoViewModel model) { var response = ResponseModelFactory.CreateInstance; using (_dbContext) { var tdinfo = _dbContext.TaskDecompInfo.FirstOrDefault(x => x.TaskDecompInfoUuid == model.TaskDecompInfoUuid); if (tdinfo == null) { response.SetFailed("该记录不存在"); return(Ok(response)); } if (tdinfo.SpecialWorkTeam != model.SpecialWorkTeam && _dbContext.TaskDecompInfo.Any(x => x.SpecialWorkTeam == model.SpecialWorkTeam)) { response.SetFailed("该专班已存在"); return(Ok(response)); } tdinfo.SpecialWorkTeam = model.SpecialWorkTeam; tdinfo.DedicatedTeamLeader = model.DedicatedTeamLeader; tdinfo.RelatedCadres = model.RelatedCadres; tdinfo.Principal = model.Principal; tdinfo.Requirement = model.Requirement; int res = _dbContext.SaveChanges(); if (res > 0) { ToLog.AddLog("添加", "成功:添加:任务分解信息详情一条数据", _dbContext); } response.SetSuccess("添加成功"); return(Ok(response)); } }
public IActionResult InfoCreate(DecompInfoViewModel model) { var response = ResponseModelFactory.CreateInstance; using (_dbContext) { var td = _dbContext.TaskDecomposition.FirstOrDefault(x => x.TaskDecompositionUuid == model.Tduuid); if (td == null) { response.SetFailed("该uuid不存在"); return(Ok(response)); } if (_dbContext.TaskDecompInfo.Any(x => x.SpecialWorkTeam == model.SpecialWorkTeam)) { response.SetFailed("该专班已存在"); return(Ok(response)); } var entity = new HaikanSmartTownCockpit.Api.Entities.TaskDecompInfo(); entity.TaskDecompInfoUuid = Guid.NewGuid(); entity.Tduuid = model.Tduuid; entity.SpecialWorkTeam = model.SpecialWorkTeam; entity.DedicatedTeamLeader = model.DedicatedTeamLeader; entity.RelatedCadres = model.RelatedCadres; entity.Principal = model.Principal; entity.Requirement = model.Requirement; entity.AddTime = DateTime.Now; entity.IsDelete = 0; _dbContext.TaskDecompInfo.Add(entity); int res = _dbContext.SaveChanges(); if (res > 0) { ToLog.AddLog("添加", "成功:添加:任务分解信息一条数据", _dbContext); } response.SetSuccess("添加成功"); return(Ok(response)); } }