public IActionResult Edit(FangxunViewModel model) { var response = ResponseModelFactory.CreateInstance; using (_dbContext) { var entity = _dbContext.FangXun.FirstOrDefault(x => x.Guid == model.Guid); if (entity == null) { response.SetFailed("不存在"); return(Ok(response)); } entity.Workingclass = model.Workingclass; entity.Teamleader = model.Teamleader; entity.Governmentofficials = model.Governmentofficials; entity.Personinchargeofvillageenterprise = model.Personinchargeofvillageenterprise; entity.Jobrequirements = model.Jobrequirements; int res = _dbContext.SaveChanges(); if (res > 0) { ToLog.AddLog("编辑", "成功:编辑:防汛应急预案信息一条数据", _dbContext); } response = ResponseModelFactory.CreateInstance; return(Ok(response)); } }
public IActionResult Create(FangxunViewModel model) { var response = ResponseModelFactory.CreateInstance; using (_dbContext) { var entity = _mapper.Map <FangxunViewModel, FangXun>(model); entity.Guid = Guid.NewGuid(); entity.IsDeleted = 0; entity.Workingclass = model.Workingclass; entity.Teamleader = model.Teamleader; entity.Governmentofficials = model.Governmentofficials; entity.Personinchargeofvillageenterprise = model.Personinchargeofvillageenterprise; entity.Jobrequirements = model.Jobrequirements; _dbContext.FangXun.Add(entity); int res = _dbContext.SaveChanges(); if (res > 0) { ToLog.AddLog("添加", "成功:添加:防汛应急预案信息一条数据", _dbContext); } response.SetSuccess(); return(Ok(response)); } }