Esempio n. 1
0
        public ActionResult EditarDia(int idOdontologista, int id)
        {
            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("DiaAgenda?"
                                           + "idClinica=" + identity.Claims.Where(c => c.Type == ClaimTypes.Sid).Select(c => c.Value).SingleOrDefault()
                                           + "&idOdontologista=" + idOdontologista + "&id=" + id)
                           .Result;

            var EmpResponse = response.Content.ReadAsStringAsync().Result;

            var dia = JsonConvert.DeserializeObject <AgendaDTL.DiaAgenda>(EmpResponse);

            var model = new DiaAgendaVM()
            {
                Id   = dia.Id,
                Data = dia.Data,
                HorarioAtendimentoInicio  = dia.HorarioAtendimentoInicio,
                HorarioAtendimentoTermino = dia.HorarioAtendimentoTermino,
                IdOdontologista           = dia.IdOdontologista
            };

            return(PartialView(model));
        }
Esempio n. 2
0
        public ActionResult AdicionarDia(int idOdontologista)
        {
            var model = new DiaAgendaVM()
            {
                IdOdontologista = idOdontologista
            };

            return(PartialView(model));
        }
Esempio n. 3
0
        public ActionResult EditarDia(DiaAgendaVM model)
        {
            var r = new ReturnArgs();

            if (ModelState.IsValid)
            {
                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.PutAsync("DiaAgenda",
                                                   new FormUrlEncodedContent(new[]
                    {
                        new KeyValuePair <string, string>("Id", model.Id.ToString()),
                        new KeyValuePair <string, string>("IdClinica", identity.Claims.Where(c => c.Type == ClaimTypes.Sid).Select(c => c.Value).SingleOrDefault()),
                        new KeyValuePair <string, string>("IdOdontologista", model.IdOdontologista.ToString()),
                        new KeyValuePair <string, string>("HorarioAtendimentoInicio", model.HorarioAtendimentoInicio.ToString()),
                        new KeyValuePair <string, string>("HorarioAtendimentoTermino", model.HorarioAtendimentoTermino.ToString()),
                        new KeyValuePair <string, string>("Data", model.Data.ToString("yyyy-MM-dd"))
                    })).Result;

                    if (response.IsSuccessStatusCode)
                    {
                        this.ShowMessage("Agenda Salva.", "Sucesso!");
                        r.Status = 1;
                        return(Json(r));
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, response.Content.ReadAsStringAsync().Result);
                        r.Status = -1;
                        r.View   = this.RenderRazorViewToString("EditarDia", model);
                        return(Json(r));
                    }
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError(string.Empty, ex);
                    r.Status = -1;
                    r.View   = this.RenderRazorViewToString("EditarDia", model);
                    return(Json(r));
                }
            }
            r.Status = -1;
            r.View   = this.RenderRazorViewToString("EditarDia", model);
            return(Json(r));
        }