Esempio n. 1
0
        public async Task <UserModel> Post([FromBody] CreateUserModel requestModel)
        {
            var item = await _query.Create(requestModel);

            var model = _mapper.Map <UserModel>(item);

            return(model);
        }
Esempio n. 2
0
        public async Task CreateShouldSaveNewUser()
        {
            var model = new CreateUserModel
            {
                Password  = _random.Next().ToString(),
                Username  = _random.Next().ToString(),
                LastName  = _random.Next().ToString(),
                FirstName = _random.Next().ToString(),
            };

            var result = await _query.Create(model);

            result.Password.Should().NotBeEmpty();
            result.UserName.Should().Be(model.Username);
            result.LastName.Should().Be(model.LastName);
            result.FirstName.Should().Be(model.FirstName);

            _uow.Verify(x => x.Add(result));
            _uow.Verify(x => x.CommitAsync());
        }
Esempio n. 3
0
        public async Task <User> Register(RegisterModel model)
        {
            var requestModel = new CreateUserModel
            {
                FirstName = model.FirstName,
                LastName  = model.LastName,
                Password  = model.Password,
                Username  = model.Username
            };

            var user = await _usersQuery.Create(requestModel);

            return(user);
        }