public HttpResponseMessage Save(Agenda agenda)
        {
            try
            {
                var agendaService = new AgendaService();

                agenda.Clinica = new Clinica()
                {
                    Id = ClinicaService.ObtemUsuarioLogadoId((User.Identity as ClaimsIdentity).Claims.ToList())
                };

                agendaService.Save(agenda);

                if (agendaService.ResponseService.Type == ResponseTypeEnum.Error)
                {
                    return(Request.CreateErrorResponse(
                               HttpStatusCode.BadRequest, agendaService.ResponseService.Message));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new
                    {
                        Message = agendaService.ResponseService.Message,
                        Type = agendaService.ResponseService.Type.ToString(),
                        Fields = agendaService.ResponseService.FieldsInvalids
                    }));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Erro ao cadastrar."));
            }
        }
        public HttpResponseMessage GetAgendaClinica(int medicoId, string data)
        {
            try
            {
                var agendaService = new AgendaService();

                var clinicaLogadoId = ClinicaService.ObtemUsuarioLogadoId((User.Identity as ClaimsIdentity).Claims.ToList());
                var agenda          = agendaService.GetAgendaClinica(clinicaLogadoId, medicoId, data);

                if (agendaService.ResponseService.Type.Equals("Error"))
                {
                    return(Request.CreateErrorResponse(
                               HttpStatusCode.BadRequest, agendaService.ResponseService.Message));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new
                    {
                        Agenda = agenda,
                        Message = agendaService.ResponseService.Message,
                        Type = agendaService.ResponseService.Type
                    }));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(
                           HttpStatusCode.BadRequest, "Erro ao recuperar a agenda."));
            }
        }