public HttpResponseMessage Conclui(int agendaId)
        {
            try
            {
                var agendaService    = new AgendaService();
                var pacienteLogadoId = PacienteService.ObtemUsuarioLogadoId((User.Identity as ClaimsIdentity).Claims.ToList());

                agendaService.Conclui(agendaId);
                var agenda = agendaService.Get(pacienteLogadoId);

                if (agendaService.ResponseService.Type == ResponseTypeEnum.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.ToString(),
                        Fields = agendaService.ResponseService.FieldsInvalids
                    }));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Erro ao confirmar."));
            }
        }
        public HttpResponseMessage GetAgendaPaciente()
        {
            try
            {
                var agendaService = new AgendaService();

                var pacienteLogadoId = PacienteService.ObtemUsuarioLogadoId((User.Identity as ClaimsIdentity).Claims.ToList());
                var agenda           = agendaService.Get(pacienteLogadoId);

                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."));
            }
        }
예제 #3
0
 public ActionResult <List <Agenda> > Get() =>
 _agendaService.Get();
        public void Agenda_Get_Paciente()
        {
            var agenda = agendaService.Get(1);

            Assert.AreEqual(ResponseTypeEnum.Success, agendaService.ResponseService.Type);
        }