public void PreencheDropDrownListCategoria()
        {
            categorias = new List <Categoria>();
            var listaCategpria = HelperSOA.CallApi(ApiCategoria, WebRequestMethods.Http.Get, string.Empty, string.Empty);

            if (listaCategpria.StatusCode == HttpStatusCode.OK)
            {
                categorias = JsonConvert.DeserializeObject <List <Categoria> >(listaCategpria.Response);
            }

            ViewBag.ListaCategoria = new SelectList(categorias.Select(c => new { c.IdCategoria, c.Descricao }).ToList(), "IdCategoria", "Descricao");
        }
Пример #2
0
        public void PreencheDropDrownListCategoria()
        {
            subcategorias = new List <SubCategoria>();
            var listasubCategpria = HelperSOA.CallApi(ApiCategoria, WebRequestMethods.Http.Get, string.Empty, string.Empty);

            if (listasubCategpria.StatusCode == HttpStatusCode.OK)
            {
                subcategorias = JsonConvert.DeserializeObject <List <SubCategoria> >(listasubCategpria.Response);
            }

            ViewBag.ListaCategoria = new SelectList(subcategorias.Select(c => new { subCategoriaSlug = c.Slug, categoriaSlug = c.Categoria.Slug }), "subCategoriaSlug", "categoriaSlug");
        }
        public ActionResult SubCategoriaCampo(int id)
        {
            PreencheDropDrownListCampo();

            var listaSubCategoria = HelperSOA.CallApi(Api, WebRequestMethods.Http.Get, id.ToString(), string.Empty);

            if (listaSubCategoria.StatusCode == HttpStatusCode.OK)
            {
                var subCategoria = JsonConvert.DeserializeObject <List <SubCategoria> >(listaSubCategoria.Response);
                return(View(subCategoria.FirstOrDefault()));
            }
            return(View());
        }
        public ActionResult ExcluirSubCategoriaCampo(int idSubCategoria, int idCampo, int ordem)
        {
            var excluiCategoria = HelperSOA.CallApi(string.Format("{0}/{1}/{2}/{3}", ApiSubCategoriaCampo, idSubCategoria, idCampo, ordem), "DELETE", string.Empty, string.Empty);

            if (excluiCategoria.StatusCode == HttpStatusCode.OK)
            {
                return(RedirectToAction("SubCategoriaCampo", new { id = idSubCategoria }));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
        public ActionResult Excluir(int Id)
        {
            var excluiCategoria = HelperSOA.CallApi(string.Format("{0}/{1}", Api, Id), "DELETE", string.Empty, string.Empty);

            if (excluiCategoria.StatusCode == HttpStatusCode.OK)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
        public ActionResult Index()
        {
            var listaSubCategoria = HelperSOA.CallApi(Api, WebRequestMethods.Http.Get, string.Empty, string.Empty);

            if (listaSubCategoria.StatusCode == HttpStatusCode.OK)
            {
                return(View(JsonConvert.DeserializeObject <IList <SubCategoria> >(listaSubCategoria.Response)));
            }
            else
            {
                return(View());
            }
        }
Пример #7
0
        public ActionResult Index(string subCategoriaSlug, string categoriaSlug)
        {
            var listaSubCategoria = HelperSOA.CallApi(string.Format("{0}/{1}/{2}", ApiSubCategoria, subCategoriaSlug, categoriaSlug), WebRequestMethods.Http.Get, string.Empty, string.Empty);

            if (listaSubCategoria.StatusCode == HttpStatusCode.OK)
            {
                var subCategoria = JsonConvert.DeserializeObject <SubCategoria>(listaSubCategoria.Response);
                return(View("Index", subCategoria));
            }
            else
            {
                return(View());
            }
        }
 public ActionResult Cadastrar(SubCategoria subcategoria)
 {
     if (ModelState.IsValid)
     {
         var subcadastraCategoria = HelperSOA.CallApi(Api, WebRequestMethods.Http.Post, JsonConvert.SerializeObject(subcategoria), string.Empty);
         if (subcadastraCategoria.StatusCode == HttpStatusCode.Created)
         {
             return(RedirectToAction("Index"));
         }
         else
         {
             return(View("Index"));
         }
     }
     else
     {
         return(View());
     }
 }