public IActionResult Edit(ResponseInfoViewModel model) { var response = ResponseModelFactory.CreateInstance; using (_dbContext) { var entity = _dbContext.ResponseInfo.FirstOrDefault(x => x.ResponseInfoUuid == model.ResponseInfoUuid); if (entity == null) { response.SetFailed("不存在"); return Ok(response); } //if (_dbContext.ResponseInfo.Count(x => x.TeamName == model.TeamName && x.ResponseInfoUuid != model.ResponseInfoUuid) > 0) //{ // response.SetFailed("名称已存在"); // return Ok(response); //} entity.Village = model.Village; entity.TongzhiRen = model.TongzhiRen; entity.XiangyingDj = model.XiangyingDj; entity.TongzhiQingk = model.TongzhiQingk; entity.Phone = model.Phone; int res = _dbContext.SaveChanges(); if (res > 0) { ToLog.AddLog("编辑", "成功:编辑:响应情况信息一条数据", _dbContext); } response = ResponseModelFactory.CreateInstance; return Ok(response); } }
public IActionResult Create(ResponseInfoViewModel model) { var response = ResponseModelFactory.CreateInstance; using (_dbContext) { //if (_dbContext.ResponseInfo.Count(x => x.MemberName == model.MemberName) > 0) //{ // response.SetFailed("名称已存在"); // return Ok(response); //} var entity = _mapper.Map<ResponseInfoViewModel, ResponseInfo>(model); entity.ResponseInfoUuid = Guid.NewGuid(); entity.IsDeleted = 0; entity.State = 0; entity.AddTime = DateTime.Now.ToString("yyyy-MM-dd"); entity.AddPeople = AuthContextService.CurrentUser.DisplayName; _dbContext.ResponseInfo.Add(entity); int res = _dbContext.SaveChanges(); if (res > 0) { ToLog.AddLog("添加", "成功:添加:响应情况信息一条数据", _dbContext); } response.SetSuccess(); return Ok(response); } }