Example #1
0
        public ActionResult Index()
        {
            var model = new PedidoViewModel();

            var clientTamanho = new ClientTamanho();

            var response = clientTamanho.GetTamanhos();

            if (response.IsSuccessStatusCode)
            {
                model.Tamanhos = response.Content.ReadAsAsync <List <TamanhoViewModel> >().Result;
            }
            else
            {
                return(Json(response, JsonRequestBehavior.AllowGet));
            }

            var clientSabor = new ClientSabor();

            response = clientSabor.GetSabores();

            if (response.IsSuccessStatusCode)
            {
                model.Sabores = response.Content.ReadAsAsync <List <SaborViewModel> >().Result;
            }
            else
            {
                return(Json(response, JsonRequestBehavior.AllowGet));
            }

            return(View(model));
        }
Example #2
0
        public ActionResult FinalizarPedido(PedidoViewModel model)
        {
            var clientPedido = new ClientPedido();

            var response = clientPedido.PutPedido(model);

            if (response.IsSuccessStatusCode)
            {
                model = response.Content.ReadAsAsync <PedidoViewModel>().Result;
            }
            else
            {
                return(Json(response, JsonRequestBehavior.AllowGet));
            }

            var clientTamanho = new ClientTamanho();

            response = clientTamanho.GetTamanhos();

            if (response.IsSuccessStatusCode)
            {
                model.Tamanho = response.Content.ReadAsAsync <List <TamanhoViewModel> >().Result.First(t => t.Id == model.Tamanho.Id);
            }
            else
            {
                return(Json(response, JsonRequestBehavior.AllowGet));
            }

            var clientSabor = new ClientSabor();

            response = clientSabor.GetSabores();

            if (response.IsSuccessStatusCode)
            {
                model.Sabor = response.Content.ReadAsAsync <List <SaborViewModel> >().Result.First(t => t.Id == model.Sabor.Id);
            }
            else
            {
                return(Json(response, JsonRequestBehavior.AllowGet));
            }

            return(PartialView("_Finalizacao", model));
        }