Exemplo n.º 1
0
        public async Task <ActionResult <UserDto> > Post(UserDto userDto)
        {
            try
            {
                var user    = _mapper.Map <User>(userDto);
                var userNew = await _userRepositories.SaveUserAsync(user);

                if (userNew == null)
                {
                    return(BadRequest());
                }
                var newuserDto = _mapper.Map <UserDto>(user);
                return(CreatedAtAction(nameof(Post), new { newuserDto.ID }, newuserDto));
            }catch (Exception ex)
            {
                return(BadRequest());
            }
        }