Esempio n. 1
0
        public ActionResult EscolherOdontologista(int idPaciente)
        {
            var client = new HttpClient();

            client.BaseAddress = new Uri(ConfigurationManager.AppSettings["service:ApiAddress"].ToString());
            client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

            var identity = (ClaimsPrincipal)Thread.CurrentPrincipal;

            var response    = client.GetAsync("Odontologista?idClinica=" + identity.Claims.Where(c => c.Type == ClaimTypes.Sid).Select(c => c.Value).SingleOrDefault()).Result;
            var EmpResponse = response.Content.ReadAsStringAsync().Result;

            //Deserializing the response recieved from web api and storing into the Employee list
            var dentistas = JsonConvert.DeserializeObject <List <AgendaDTL.Odontologista> >(EmpResponse);

            var model = new AgendamentoVM();

            model.IdPaciente = idPaciente;

            ViewBag.OdontoId = new SelectList(
                dentistas,
                "Id",
                "Nome"
                );

            ViewBag.IdClinica = identity.Claims.Where(c => c.Type == ClaimTypes.Sid).Select(c => c.Value).SingleOrDefault();

            return(View(model));
        }
        public async Task <ActionResult> Post([FromBody] AgendamentoVM agendamento)
        {
            try
            {
                var Builder = BuilderEntidade.ConverteEntidade <Agendamento>(agendamento);
                await _entityService.Salvar(Builder);

                return(StatusCode(200));
            }
            catch (System.Exception er)
            {
                return(StatusCode(401, new { er.Message }));
            }
        }
Esempio n. 3
0
        public ActionResult Protocolo(int idPaciente, int idAgenda, string data, string horario)
        {
            try
            {
                var client = new HttpClient();
                client.BaseAddress = new Uri(ConfigurationManager.AppSettings["service:ApiAddress"].ToString());
                client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

                var identity = (ClaimsPrincipal)Thread.CurrentPrincipal;

                var response = client.PostAsync("Agendamento",
                                                new FormUrlEncodedContent(new[]
                {
                    new KeyValuePair <string, string>("IdAgenda", idAgenda.ToString()),
                    new KeyValuePair <string, string>("IdPaciente", idPaciente.ToString()),
                    new KeyValuePair <string, string>("Data", data),      //.ToString("yyyy-MM-dd")),
                    new KeyValuePair <string, string>("Horario", horario) //.ToString("hh:mm"))
                })).Result;

                var model = new AgendamentoVM()
                {
                    IdPaciente      = idPaciente,
                    IdAgenda        = idAgenda,
                    DataAgendamento = Convert.ToDateTime(data),
                    HoraAgendamento = TimeSpan.Parse(horario)
                };
                if (response.IsSuccessStatusCode)
                {
                    return(View(model));
                }
                else
                {
                    model.IdPaciente = 0;
                    ModelState.AddModelError(string.Empty, response.Content.ReadAsStringAsync().Result);
                    return(View(model));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex);
                return(View());
            }
        }