Beispiel #1
0
        public ActionResult Delete(int?id)
        {
            ProdutoSubcategoria          Subcategoria   = Service.GetById(id.GetValueOrDefault());
            ProdutoSubcategoriaViewModel SubcategoriaVM = Mapper.Map <ProdutoSubcategoria, ProdutoSubcategoriaViewModel>(Subcategoria);

            return(View(SubcategoriaVM));
        }
Beispiel #2
0
        public ActionResult Edit(int?id)
        {
            ProdutoSubcategoria          Subcategoria   = Service.GetById(id.GetValueOrDefault());
            ProdutoSubcategoriaViewModel SubcategoriaVM = Mapper.Map <ProdutoSubcategoria, ProdutoSubcategoriaViewModel>(Subcategoria);

            ProdutoCategoriaService Categorias = new ProdutoCategoriaService();

            ViewBag.CategoriaId = new SelectList(Categorias.GetAll(), "CategoriaId", "Nome");

            return(View(SubcategoriaVM));
        }
Beispiel #3
0
        public ActionResult Create([Bind(Include = "SubcategoriaId,Nome,CategoriaId")] ProdutoSubcategoriaViewModel produtoSubcategoriaViewModel)
        {
            if (ModelState.IsValid)
            {
                ProdutoSubcategoria Subcategoria = Mapper.Map <ProdutoSubcategoriaViewModel, ProdutoSubcategoria>(produtoSubcategoriaViewModel);
                Service.Insert(Subcategoria);
                return(RedirectToAction("Index"));
            }

            ProdutoCategoriaService Categorias = new ProdutoCategoriaService();

            ViewBag.CategoriaId = new SelectList(Categorias.GetAll(), "CategoriaId", "Nome");
            return(View(produtoSubcategoriaViewModel));
        }