Exemplo n.º 1
0
        public UserDTO UpdateUser(UserDTO userDTO)
        {
            ValidateUser(userDTO);

            User user = userRepository.GetByKey(userDTO.ID);

            user = ReflectUtil.UpdateNotEmptyValues(userDTO, user);
            userRepository.Update(user);
            RepositoryContext.Commit();
            return(Mapper.Map <User, UserDTO>(user));
        }
Exemplo n.º 2
0
        public void UpdateAllNotNullOrEmptyTest()
        {
            User    user    = new User("qianlifeng", "qlf", "*****@*****.**", "test", null);
            UserDTO userDTO = new UserDTO
            {
                UserName = "******",
                NickName = "qlf2"
            };

            User userNew = ReflectUtil.UpdateNotEmptyValues(userDTO, user);

            Assert.IsTrue(userNew.UserName == userDTO.UserName);
            Assert.IsTrue(userNew.NickName == userDTO.NickName);
            Assert.IsTrue(userNew.Email != userDTO.Email);
        }