public IActionResult Edit(WorkManageViewModel model) { var response = ResponseModelFactory.CreateInstance; using (_dbContext) { var entity = _dbContext.PaibanInfo.FirstOrDefault(x => x.PaibanInfoUuid == model.PaibanInfoUuid); if (entity == null) { response.SetFailed("不存在"); return(Ok(response)); } entity.ZbLingdao = model.ZbLingdao; entity.Zbrenyuan = model.Zbrenyuan; entity.Zyrenyuan = model.Zyrenyuan; entity.ZbBc = model.ZbBc; entity.ZbTime = model.ZbTime; int res = _dbContext.SaveChanges(); if (res > 0) { ToLog.AddLog("编辑", "成功:编辑:排班信息一条数据", _dbContext); } response = ResponseModelFactory.CreateInstance; return(Ok(response)); } }
public IActionResult Create(WorkManageViewModel model) { var response = ResponseModelFactory.CreateInstance; using (_dbContext) { var entity = new HaikanSmartTownCockpit.Api.Entities.PaibanInfo(); entity.PaibanInfoUuid = Guid.NewGuid(); entity.ZbLingdao = model.ZbLingdao; entity.Zbrenyuan = model.Zbrenyuan; entity.Zyrenyuan = model.Zyrenyuan; entity.ZbBc = model.ZbBc; entity.ZbTime = model.ZbTime; entity.IsDeleted = 0; _dbContext.PaibanInfo.Add(entity); int res = _dbContext.SaveChanges(); if (res > 0) { ToLog.AddLog("添加", "成功:添加:排班信息一条数据", _dbContext); } response.SetSuccess(); return(Ok(response)); } }