public bool Update(SysUser model) { model.UpdateTime = DateTime.Now; _userRepository.Update(model); var res = _uow.Commit(); return(res > 0); }
public void UpdateUserPwd(long id, string pwd) { pwd = Encrypt.DesDecrypt(pwd); sys_user dto = _sysuserRepository.GetById(id); dto.pass_word = pwd ?? string.Empty; dto.account_name = dto.account_name ?? string.Empty; dto.real_name = dto.real_name ?? string.Empty; dto.mobile_phone = dto.mobile_phone ?? string.Empty; dto.email = dto.email ?? string.Empty; dto.fax = dto.fax ?? string.Empty; dto.create_person = dto.create_person ?? string.Empty; dto.create_time = dto.create_time; dto.is_super = dto.is_super; dto.sys_role_id = dto.sys_role_id; dto.province = dto.province; dto.city = dto.city; dto.county = dto.county; dto.user_level = dto.user_level; dto.remark = dto.remark ?? string.Empty; _sysuserRepository.Update(dto); }
public void SubmitForm(UserInputDto userInputDto, UserInfo userinfo) { if (!string.IsNullOrEmpty(userInputDto.Id)) //更新 { SysUserEntity entity = _sysUserRepository.Get(userInputDto.Id); entity.UserName = userInputDto.UserName; entity.TrueName = userInputDto.TrueName; entity.QQ = userInputDto.QQ; entity.PhoneNumber = userInputDto.PhoneNumber; if (!string.IsNullOrEmpty(userInputDto.RoleId)) { SysRole2UserEntity roleEntity = _sysRole2UserRepository.GetAll().Where(t => t.SysRoleId.Equals(userInputDto.Id)).FirstOrDefault(); if (roleEntity != null) { roleEntity.SysRoleId = userInputDto.RoleId; _sysRole2UserRepository.Update(roleEntity); } else { roleEntity = new SysRole2UserEntity(); roleEntity.Id = Guid.NewGuid().ToString(); roleEntity.SysRoleId = userInputDto.RoleId; roleEntity.SysUserId = entity.Id; _sysRole2UserRepository.Insert(roleEntity); } } _sysUserRepository.Update(entity); } else { SysUserEntity entity = AutoMapper.Mapper.Map <SysUserEntity>(userInputDto); entity.Id = Guid.NewGuid().ToString(); entity.Password = Common.Utils.Md5.GetMD5("123456"); entity.CreatePerson = userinfo.UserID; entity.CreateTime = DateTime.Now; _sysUserRepository.Insert(entity); SysRole2UserEntity roleEntity = new SysRole2UserEntity(); roleEntity.Id = Guid.NewGuid().ToString(); roleEntity.SysRoleId = userInputDto.RoleId; roleEntity.SysUserId = entity.Id; _sysRole2UserRepository.Insert(roleEntity); } }
public void UpdateAccount(Entities.SysUser account) { service.Update(account); }
public void Update(SysUserViewModel sysUserViewModel) { _sysUserRepository.Update(_mapper.Map <Sys_User>(sysUserViewModel)); }
public async Task <IActionResult> Put(int id, [FromBody] sys_user value) { if (id == 0) { //修改密码 var usr = _sysUserRpt.GetSingle(f => f.Id == value.Id); if (usr != null) { usr.Pwd = value.Pwd; _sysUserRpt.Update(usr); _sysUserRpt.Commit(); } } else { using (var tran = _context.Database.BeginTransaction()) { try { sys_user userDb = _sysUserRpt.GetSingle(id); if (userDb == null) { return(NotFound()); } if (value.RoleIds != userDb.RoleIds) { //修改了用户角色 _sysRoleUserRpt.DeleteWhere(f => f.UserId == id); _sysRoleUserRpt.Commit(); //新增用户角色关系表 string[] roles = value.RoleIds.Split(",".ToArray()); foreach (var item in roles) { if (!string.IsNullOrEmpty(item)) { var userrole = new sys_role_user { RoleId = int.Parse(item), UserId = id }; _sysRoleUserRpt.Add(userrole); } } _sysRoleUserRpt.Commit(); } userDb.IsValid = value.IsValid; userDb.Mobile = value.Mobile; userDb.Tel = value.Tel; userDb.Works = value.Works; userDb.Title = value.Title; userDb.UserId = value.UserId; userDb.UserName = value.UserName; userDb.UpdatedAt = DateTime.Now; userDb.RoleIds = value.RoleIds; _sysUserRpt.Commit(); tran.Commit(); } catch (Exception ex) { Console.WriteLine(ex); tran.Rollback(); return(BadRequest(ex)); } } } return(new NoContentResult()); }
public int UpdateUser(SysUser user) { return(userDao.Update(user)); }