public async Task <IActionResult> CreateAsync([FromBody] CreateAgendaRequest agendaRequest) { var agenda = await agendaService.AddAsync(mapper.Map <Agenda>(agendaRequest)); if (agenda == null) { var errorResponse = new ErrorResponse(); errorResponse.Errors.Add(new ErrorData { Message = "Não foi possivel criar um agendamento" }); return(BadRequest(errorResponse)); } var baseUrl = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.ToUriComponent()}"; var locationUri = baseUrl + "/" + ApiRoutes.Agenda.Get.Replace("{id}", agenda.Id.ToString()); return(Created(locationUri, new { })); }