Пример #1
0
        public StoreUserResponse StoreUser(StoreUserRequest request)
        {
            StoreUserResponse         response = new StoreUserResponse();
            SecurityBusinessComponent bc       = DependencyInjectionHelper.GetSecurityBusinessComponent();

            User user = SecurityAdapter.DtoToUser(request.User);
            IEnumerable <ChangeItem> changeItems = SecurityAdapter.GetChangeItems(request.User);

            response.Id = bc.StoreUser(user, changeItems);

            return(response);
        }
        public void TestDtoToUser()
        {
            RoleDTO roleDTO = new RoleDTO()
            {
                Id = 1, RoleName = "FakeName", Version = 0
            };
            UserDTO dto = new UserDTO()
            {
                Id = 1, UserName = "******", Password = "******", Version = 1
            };

            dto.Roles.Add(roleDTO);
            Assert.AreEqual(true, dto.IsValid);
            Assert.AreEqual(true, roleDTO.IsValid);

            User user = SecurityAdapter.DtoToUser(dto);

            Assert.AreEqual <int>(dto.Id, user.UserId);
            Assert.AreEqual <string>(dto.UserName, user.UserName);
            Assert.AreEqual <string>(dto.Password, user.Password);
            Assert.AreEqual(dto.Version, user.Version);
            Assert.AreEqual(true, user.IsValid);
        }