public async Task <IActionResult> Register(ApplicationUserRegisterRequest model) { Response oR = new Response(); try { if (!ModelState.IsValid) { oR.Status = StatusCodes.Status400BadRequest; oR.Message = Messages.ValidationsFailed; oR.Data = GetModelErrors(ModelState); return(BadRequest(oR)); } if (await _service.ExistsUserName(model.UserName)) { oR.Status = StatusCodes.Status400BadRequest; oR.Message = "El nombre de usuario ya está en uso."; return(BadRequest(oR)); } if (await _service.ExistsEmail(model.Email)) { oR.Status = StatusCodes.Status400BadRequest; oR.Message = "El correo electronico ya está en uso."; return(BadRequest(oR)); } if (!await _service.Register(model)) { oR.Status = StatusCodes.Status500InternalServerError; oR.Message = Messages.InternalServerError; return(StatusCode(StatusCodes.Status500InternalServerError, oR)); } oR.Status = StatusCodes.Status200OK; return(Ok(oR)); } catch (Exception ex) { oR.Status = StatusCodes.Status500InternalServerError; oR.Message = Messages.InternalServerError; return(StatusCode(StatusCodes.Status500InternalServerError, oR)); } }