Esempio n. 1
0
        public async Task <ActionResult <BasicUserViewModel> > UpdateUserAsync(string username, UpdateUserCommand updateUserCommand)
        {
            var existingUser = await _queries.FindByUsernameAsync(username);

            if (existingUser == null)
            {
                return(NotFound());
            }

            var user = _mapper.Map <User>(existingUser);

            _mapper.Map(updateUserCommand, user);
            await _behavior.UpdateUserAsync(user);

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

            return(userViewModel);
        }
Esempio n. 2
0
        public async Task <IActionResult> UpdateUserAsync(string username, UpdateUserCommand updateUserCommand)
        {
            // We are re-using existing Queries
            // you can also provide methods on the repository
            // (they could be exposed through a behavior class)
            // strictly related with transactional logic and
            // completely specialize your queries with data displaying tasks.
            var existingUser = await _queries.FindByUsernameAsync(username);

            if (existingUser == null)
            {
                return(NotFound());
            }

            _mapper.Map(updateUserCommand, existingUser);
            await _behavior.UpdateUserAsync(existingUser);

            return(NoContent());
        }