public async Task <Writter.API.Dto.User> AutenticateUser(Writter.API.Dto.WritterLoginRequest user) { try { var newUser = _mapper.Map <Writter.Domain.Dto.WritterLoginRequest>(user); var response = _mapper.Map <Writter.API.Dto.User>(await _service.AutenticateUser(newUser)); return(response); } catch (Exception ex) { return(null); } }
public async Task <IActionResult> AutenticateUser([FromBody] Writter.API.Dto.WritterLoginRequest request) { try { if (!ModelState.IsValid) { var message = ModelState.ToDictionary(d => d.Key, d => d.Value.Errors.Select(e => e.ErrorMessage).ToList()); return(BadRequest(message)); } var result = await _facade.AutenticateUser(request); return(Ok(result)); } catch (Exception ex) { log.Error(new Exception(), ex.Message); } return(null); }