public void UpdateUser(FullUserEntity fullUserEntity) { uow.UserRoleRepository.DeleteAllByUserId(fullUserEntity.Id); fullUserEntity.Roles.ToList().ForEach(x => uow.UserRoleRepository.Create(new UserRoleEntity { UserId = fullUserEntity.Id, RoleId = x.Id }.ToDalUserRole())); uow.Commit(); }
public void UpdateUserRoles(FullUserEntity user) { uow.UserRoleRepository.DeleteAllByUserId(user.Id); user.Roles.ToList().ForEach(x => uow.UserRoleRepository.Create(new DalUserRole() { UserId = user.Id, RoleId = x.Id })); uow.Commit(); }
public static FullUserViewModel ToMvcUser(this FullUserEntity userEntity) { return(new FullUserViewModel { Id = userEntity.Id, Name = userEntity.Name, Surname = userEntity.Surname, NickName = userEntity.NickName, Email = userEntity.Email, Password = userEntity.Password, JoinTime = userEntity.JoinTime, Roles = userEntity.Roles.Select(x => x.ToMvcRole()) }); }
public static DalUser ToDalUser(this FullUserEntity fullUser) { return(new DalUser() { Id = fullUser.Id, Name = fullUser.Name, Surname = fullUser.Surname, NickName = fullUser.NickName, Password = fullUser.Password, Email = fullUser.Email, JoinTime = fullUser.JoinTime, AvatarPath = fullUser.AvatarPath }); }
public static FullUserViewModel ToFullMvcUser(this FullUserEntity fullEntity) { return new FullUserViewModel { Id = fullEntity.Id, Name = fullEntity.Name, Surname = fullEntity.Surname, NickName = fullEntity.NickName, Password = fullEntity.Password, Email = fullEntity.Email, JoinTime = fullEntity.JoinTime, AvatarPath = fullEntity.AvatarPath, Roles = fullEntity.Roles.Select(role => role.ToMvcSimpleRole()) }; }
public FullUserEntity GetFullUserEntity(UserEntity e) { if (e == null) { return(null); } var result = new FullUserEntity { Id = e.Id, Name = e.Name, Surname = e.Surname, NickName = e.NickName, Password = e.Password, Email = e.Email, JoinTime = e.JoinTime, AvatarPath = e.AvatarPath, Roles = uow.UserRoleRepository.GetAll().Where(role => role.UserId == e.Id).Select(x => uow.RoleRepository.GetById(x.RoleId)?.ToBllRole()) }; return(result); }
public void CreateUser(FullUserEntity userEntity) { if (userEntity == null) { return; } var newUser = new UserEntity { Id = userEntity.Id, Name = userEntity.Name, Surname = userEntity.Surname, NickName = userEntity.NickName, Email = userEntity.Email, Password = userEntity.Password, JoinTime = userEntity.JoinTime }; uow.UserRepository.Create(newUser.ToDalUser()); userEntity.Roles.Select(x => new UserRoleEntity { UserId = userEntity.Id, RoleId = x.Id }.ToDalUserRole()).ToList().ForEach(x => uow.UserRoleRepository.Create(x)); uow.Commit(); }
public void CreateFullUser(FullUserEntity fullUser) { if (fullUser == null) { return; } var user = new UserEntity { Id = fullUser.Id, Name = fullUser.Name, Surname = fullUser.Surname, NickName = fullUser.NickName, Password = fullUser.Password, Email = fullUser.Email, JoinTime = fullUser.JoinTime, AvatarPath = fullUser.AvatarPath }; uow.UserRepository.Create(user.ToDalUser()); fullUser.Roles.Select(x => new UserRoleEntity { UserId = fullUser.Id, RoleId = x.Id }.ToDalUserRole()).ToList().ForEach(x => uow.UserRoleRepository.Create(x)); uow.Commit(); }
public void DeleteUser(FullUserEntity user) { uow.UserRepository.Delete(user.ToDalUser()); // uow.Commit(); }