public virtual int UpdateNotice(NoticeInputDto noticeInputDto) { var notice = _mapper.Map <EmsTrainNotice>(noticeInputDto); _defaultDbContext.Attach(notice); _defaultDbContext.EmsTrainNotices.Update(notice); return(_defaultDbContext.SaveChanges()); }
public virtual int UpdateTrainPlanWeek(TrainPlanWeekInputDto trainPlanWeekInputDto) { var trainPlanWeek = _mapper.Map <EmsTrainPlanWeek>(trainPlanWeekInputDto); _defaultDbContext.Attach(trainPlanWeek); _defaultDbContext.EmsTrainPlanWeeks.Update(trainPlanWeek); return(_defaultDbContext.SaveChanges()); }
public int UpdateUser(UserInputDto userInputDto) { var user = _defaultDbContext.MbpUsers.Where(u => u.Id == userInputDto.Id).FirstOrDefault(); user.IsAdmin = userInputDto.IsAdmin; user.PhoneNumber = userInputDto.PhoneNumber; user.UserName = userInputDto.UserName; user.Code = userInputDto.Code; user.Email = userInputDto.Email; _defaultDbContext.Attach(user); _defaultDbContext.MbpUsers.Update(user); return(_defaultDbContext.SaveChanges()); }
public virtual int UpdateRole(RoleInputDto roleInputDto) { var role = _mapper.Map <MbpRole>(roleInputDto); _defaultDbContext.Attach(role); _defaultDbContext.MbpRoles.Update(role); return(_defaultDbContext.SaveChanges()); }
public virtual int UpdateTrainScore(TrainScoreInputDto trainScoreInputDto) { var trainScore = _mapper.Map <EmsTrainScore>(trainScoreInputDto); _defaultDbContext.Attach(trainScore); _defaultDbContext.EmsTrainScores.Update(trainScore); return(_defaultDbContext.SaveChanges()); }
public virtual int UpdateUser(UserInputDto userInputDto) { // todo 写入mbpuserdept表 mbpuser表冗余部门信息 //var user = _defaultDbContext.MbpUsers.Where(u => u.Id == userInputDto.Id).FirstOrDefault(); var user = _mapper.Map <MbpUser>(userInputDto); //user.IsAdmin = userInputDto.IsAdmin; //user.PhoneNumber = userInputDto.PhoneNumber; //user.UserName = userInputDto.UserName; //user.Code = userInputDto.Code; //user.Email = userInputDto.Email; _defaultDbContext.Attach(user); _defaultDbContext.MbpUsers.Update(user); return(_defaultDbContext.SaveChanges()); }
public virtual int UpdateTrainPlanQuarter(TrainPlanQuarterInputDto trainPlanQuarterInputDto) { var trainPlanQuarter = _mapper.Map <EmsTrainPlanQuarter>(trainPlanQuarterInputDto); _defaultDbContext.Attach(trainPlanQuarter); _defaultDbContext.EmsTrainPlanQuarters.Update(trainPlanQuarter); return(_defaultDbContext.SaveChanges()); }
public virtual int RestPwd(string loginName, string pwd) { var user = _defaultDbContext.MbpUsers.Where(u => u.LoginName == loginName).FirstOrDefault(); user.Password = ApplicationHelper.EncryptPwdMd5(pwd); _defaultDbContext.Attach(user); _defaultDbContext.MbpUsers.Update(user); return(_defaultDbContext.SaveChanges()); }
public virtual int UpdateTrainPlanMonth(TrainPlanMonthInputDto trainPlanMonthInputDto) { var trainPlanMonth = _mapper.Map <EmsTrainPlanMonth>(trainPlanMonthInputDto); _defaultDbContext.Attach(trainPlanMonth); _defaultDbContext.EmsTrainPlanMonths.Update(trainPlanMonth); return(_defaultDbContext.SaveChanges()); }
public virtual int UpdateSubject(TrainSubjectInputDto trainSubjectInputDto) { var subject = _mapper.Map <EmsTrainSubject>(trainSubjectInputDto); _defaultDbContext.Attach(subject); _defaultDbContext.EmsTrainSubjects.Update(subject); return(_defaultDbContext.SaveChanges()); }
public IActionResult modifyDoctor(Doctor doctor) { var context = new DefaultDbContext(); if (doctor.IdDoctor == null || doctor.IdDoctor == 0) { return(NotFound()); } context.Attach(doctor).State = EntityState.Modified; context.SaveChanges(); return(Ok(doctor)); }
public virtual int UpdatePosition(PositionInputDto PositionInputDto) { var Position = _mapper.Map <MbpPosition>(PositionInputDto); // 重新继承父级信息, todo优化 可以将此逻辑放到实体里面,当作领域逻辑 var parentPosition = _defaultDbContext.MbpPositions.Where(m => m.Id == PositionInputDto.ParentId).FirstOrDefault(); // 判断选择的上级是不是自己的下级岗位,这种选择是不合理的 if (parentPosition.FullPositionName.StartsWith(Position.FullPositionName)) { throw new Exception("不能使用当前下级岗位作为父级岗位"); } // 刷新节点信息 { // 刷新当前节点 Position.SystemCode = parentPosition.SystemCode; Position.FullPositionName = string.Concat(parentPosition.FullPositionName, "/", Position.PositionName); Position.Level = parentPosition.Level + 1; Position.ParentPositionCode = parentPosition.PositionCode; Position.ParentPositionName = parentPosition.PositionName; _defaultDbContext.Attach(Position); // 刷新下级节点 var current = _defaultDbContext.MbpPositions.Include("ChildrenPosition.ChildrenPosition.ChildrenPosition.ChildrenPosition.ChildrenPosition") .First(m => m.Id == Position.Id); RefreshChildrenInfo(Position, current.ChildrenPosition); _defaultDbContext.Attach(current); } _defaultDbContext.Update(Position); // 提交所有修改 return(_defaultDbContext.SaveChanges()); }
public virtual int UpdateDept(DeptInputDto deptInputDto) { var dept = _mapper.Map <MbpDept>(deptInputDto); // 重新继承父级信息, todo优化 可以将此逻辑放到实体里面,当作领域逻辑 var parentDept = _defaultDbContext.MbpDepts.Where(m => m.Id == deptInputDto.ParentId).FirstOrDefault(); // 判断选择的上级是不是自己的下级部门,这种选择是不合理的 if (parentDept.FullDeptName.StartsWith(dept.FullDeptName)) { throw new Exception("不能使用当前下级部门作为父级部门"); } // 刷新节点信息 { // 刷新当前节点 dept.SystemCode = parentDept.SystemCode; dept.FullDeptName = string.Concat(parentDept.FullDeptName, "/", dept.DeptName); dept.Level = parentDept.Level + 1; dept.ParentDeptCode = parentDept.DeptCode; dept.ParentDeptName = parentDept.DeptName; _defaultDbContext.Attach(dept); // 刷新下级节点 var current = _defaultDbContext.MbpDepts.Include("ChildrenDept.ChildrenDept.ChildrenDept.ChildrenDept.ChildrenDept") .First(m => m.Id == dept.Id); RefreshChildrenInfo(dept, current.ChildrenDept); _defaultDbContext.Attach(current); } _defaultDbContext.Update(dept); // 提交所有修改 return(_defaultDbContext.SaveChanges()); }
public int UpdateMenu(MenuInputDto menuInputDto) { var menu = _mapper.Map <MbpMenu>(menuInputDto); _defaultDbContext.Attach(menu); // 重新继承父级信息, to do优化 var parentMenu = _defaultDbContext.MbpMenus.Where(m => m.Id == menuInputDto.ParentId).FirstOrDefault(); menu.SystemCode = parentMenu.SystemCode; menu.CodePath = string.Concat(parentMenu.CodePath, "/", menuInputDto.Code); _defaultDbContext.MbpMenus.Update(menu); return(_defaultDbContext.SaveChanges()); }