public UserResult Create(UserParam param)
        {
            Data.Entity.User entity = UserParamConverter.Convert(param, null);
            UserDao.Save(entity);

            return(UserResultConverter.Convert(entity));
        }
        public UserResult Find(long id)
        {
            Data.Entity.User entity = UserDao.Find(id);
            UserResult       result = UserResultConverter.Convert(entity);

            return(result);
        }
        public Data.Entity.User Save(Data.Entity.User entity)
        {
            UserStorage.UserList.Add(entity);
            UserStorage.UserDictionary.Add(entity.Id, entity);

            return(entity);
        }
示例#4
0
        public static void CreateUser(User request, IDacUser dacUser)
        {
            if (dacUser.Single(u => u.Username.Equals(request.Username)) != null)
            {
                throw new Exception("username already used");
            }

            if (dacUser.Single(u => u.Email.Equals(request.Email)) != null)
            {
                throw new Exception("email already used");
            }

            var user = new Data.Entity.User
            {
                Id       = request.Id,
                Username = request.Username,
                Password = Crypt.ToSHA256(request.Password),
                Name     = request.Name,
                Email    = request.Email,
                Gender   = request.Gender,
                Phone    = request.Phone,
                Role     = request.Role
            };

            dacUser.Insert(user);
            dacUser.Commit();
        }
示例#5
0
        public static Domain.Entity.User MapToDomain(Data.Entity.User user)
        {
            var result = new Domain.Entity.User();

            result.IdUser = user.IdUser;
            result.Name   = user.Name;
            return(result);
        }
        public void Update(List <UserParam> param)
        {
            List <Data.Entity.User> entity = new List <Data.Entity.User>();

            foreach (var item in param)
            {
                Data.Entity.User oldEntity = UserDao.Find(item.Id);
                Data.Entity.User newEntity = UserParamConverter.Convert(item, null);
                UserDao.Update(newEntity);
            }
        }
        public UserResult Convert(Data.Entity.User param)
        {
            UserResult result = new UserResult()
            {
                Id = param.Id,

                Username = param.Username,
                Password = param.Password
            };

            return(result);
        }
示例#8
0
        public void UserService_getbyid_simple_user()
        {
            var idUser   = Guid.NewGuid();
            var dataUser = new Data.Entity.User {
                Name = "data User"
            };

            _userRepository.Setup(x => x.GetById(It.IsAny <Guid>())).Returns(dataUser);

            var result = _userService.GetById(idUser);

            _userRepository.Verify(x => x.GetById(It.IsAny <Guid>()), Times.Once());
        }
        public Data.Entity.User Convert(UserParam param, Data.Entity.User oldentity)
        {
            Data.Entity.User entity = null;

            if (oldentity != null)
            {
                entity = oldentity;
            }
            else
            {
                entity = new Data.Entity.User
                {
                    Id = param.Id
                };
            }

            entity.Password = param.Password;
            entity.Username = param.Username;

            return(entity);
        }
        static UserStorage()
        {
            Data.Entity.User User1 = new Data.Entity.User
            {
                Id       = 11,
                Password = "******",
                Username = "******"
            };

            Data.Entity.User User2 = new Data.Entity.User
            {
                Id       = 21,
                Password = "******",
                Username = "******"
            };

            Data.Entity.User User3 = new Data.Entity.User
            {
                Id       = 31,
                Password = "******",
                Username = "******"
            };
            Data.Entity.User User4 = new Data.Entity.User
            {
                Id       = 41,
                Password = "******",
                Username = "******"
            };
            Data.Entity.User User5 = new Data.Entity.User
            {
                Id       = 51,
                Password = "******",
                Username = "******"
            };
            Data.Entity.User User6 = new Data.Entity.User
            {
                Id       = 61,
                Password = "******",
                Username = "******"
            };
            Data.Entity.User User7 = new Data.Entity.User
            {
                Id       = 71,
                Password = "******",
                Username = "******"
            };
            Data.Entity.User User8 = new Data.Entity.User
            {
                Id       = 81,
                Password = "******",
                Username = "******"
            };
            Data.Entity.User User9 = new Data.Entity.User
            {
                Id       = 91,
                Password = "******",
                Username = "******"
            };
            Data.Entity.User User10 = new Data.Entity.User
            {
                Id       = 101,
                Password = "******",
                Username = "******"
            };

            UserList.Add(User1);
            UserList.Add(User2);
            UserList.Add(User3);
            UserList.Add(User4);
            UserList.Add(User5);
            UserList.Add(User6);
            UserList.Add(User7);
            UserList.Add(User8);
            UserList.Add(User9);
            UserList.Add(User10);

            UserDictionary.Add(User1.Id, User1);
            UserDictionary.Add(User2.Id, User2);
            UserDictionary.Add(User3.Id, User3);
            UserDictionary.Add(User4.Id, User4);
            UserDictionary.Add(User5.Id, User5);
            UserDictionary.Add(User6.Id, User6);
            UserDictionary.Add(User7.Id, User7);
            UserDictionary.Add(User8.Id, User8);
            UserDictionary.Add(User9.Id, User9);
            UserDictionary.Add(User10.Id, User10);
        }
示例#11
0
 public Data.Entity.User Update(Data.Entity.User entity)
 {
     Delete(entity.Id);
     Save(entity);
     return(entity);
 }
示例#12
0
 public void Delete(Data.Entity.User entity)
 {
     UserData.Data.Remove(entity.Id);
 }
示例#13
0
 public void Delete(long id)
 {
     Data.Entity.User entity = Find(id);
     Delete(entity);
 }
示例#14
0
 public UserResult Find(long id)
 {
     Data.Entity.User entity = Dao.Find(id);
     return(ResultConverter.Convert(entity));
 }
 public void Update(long id, UserParam param)
 {
     Data.Entity.User oldEntity = UserDao.Find(id);
     Data.Entity.User newEntity = UserParamConverter.Convert(param, null);
     UserDao.Update(newEntity);
 }
示例#16
0
 public Data.Entity.User Save(Data.Entity.User entity)
 {
     UserData.Data.Add(entity.Id, entity);
     return(entity);
 }
 public void Delete(Data.Entity.User entity)
 {
     UserStorage.UserList.Remove(entity);
     UserStorage.UserDictionary.Remove(entity.Id);
 }