예제 #1
0
 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();
 }
예제 #2
0
 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();
 }
예제 #3
0
 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())
     });
 }
예제 #4
0
 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
     });
 }
예제 #5
0
 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())
     };
 }
예제 #6
0
        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);
        }
예제 #7
0
        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();
        }
예제 #8
0
        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();
        }
예제 #9
0
 public void DeleteUser(FullUserEntity user)
 {
     uow.UserRepository.Delete(user.ToDalUser());
     //
     uow.Commit();
 }