Exemple #1
0
        public async Task <ActionResult <BasicUserViewModel> > CreateUserAsync(CreateUserCommand createUserCommand)
        {
            var user = _mapper.Map <User>(createUserCommand);
            await _behavior.CreateUserAsync(user);

            var userViewModel = await _queries.FindByUsernameAsync(user.Username);

            return(userViewModel);
        }
Exemple #2
0
        public async Task <ActionResult <User> > CreateUserAsync(CreateUserCommand createUserCommand)
        {
            var user = _mapper.Map <User>(createUserCommand);
            await _behavior.CreateUserAsync(user);

            return(CreatedAtAction(
                       nameof(GetByUsernameAsync),
                       new { username = user.Username },
                       _mapper.Map <BasicUserViewModel>(user)));
        }
Exemple #3
0
        public async Task <ActionResult <User> > CreateUserAsync(CreateUserCommand createUserCommand)
        {
            var existingUser = await _queries.FindByUsernameAsync(createUserCommand.Username);

            if (existingUser != null)
            {
                return(Conflict());
            }

            var user = _mapper.Map <User>(createUserCommand);
            await _behavior.CreateUserAsync(user);

            return(user);
        }