public ResModel UpdateRepairItemType(RepairItemTypeDto repairItemTypeDto, UserDto operationUser) { using (var db = new ModelContext()) { var repairItemType = db.RepairItemType.FirstOrDefault(i => i.Id == repairItemTypeDto.Id); if (repairItemType == null) { return(new ResModel() { Msg = "更新维修项目类型失败,未找到该维修项目类型", Success = false }); } try { repairItemType.Name = repairItemTypeDto.Name; repairItemType.Description = repairItemTypeDto.Description; db.SaveChanges(); } catch (Exception e) { return(new ResModel() { Msg = "更新维修项目类型失败", Success = false }); } return(new ResModel() { Msg = "更新维修项目类型成功", Success = true }); } }
public ResModel AddRepairItemType(RepairItemTypeDto repairItemTypeDto, UserDto operationUser) { using (var db = new ModelContext()) { var repairItemType = new RepairItemType() { Id = Guid.NewGuid(), Name = repairItemTypeDto.Name, Description = repairItemTypeDto.Description }; try { db.RepairItemType.Add(repairItemType); db.SaveChanges(); } catch (Exception e) { return(new ResModel() { Msg = "添加维修项目类型失败", Success = false }); } return(new ResModel() { Msg = "添加维修项目类型成功", Success = true }); } }
public ResModel UpdateRepairItemType(RepairItemTypeDto repairItemTypeDto, UserDto operationUser) { return(_repairItemTypeRepository.UpdateRepairItemType(repairItemTypeDto, operationUser)); }
public ActionResult Update(RepairItemTypeDto repairItemTypeDto) { var currentUser = Session["LogUser"] as UserDto; return(Json(_repairItemTypeService.UpdateRepairItemType(repairItemTypeDto, currentUser))); }