예제 #1
0
        public ActionResult Details(int id)
        {
            var bllCategoria = new dtoCategoria();
            var categoria    = bllCategoria.BuscarCategoria(id);

            App_Start.AutoMapperWebConfiguration.Configure();
            var categoriasViewmodel = Mapper.Map <dtoCategoria, CategoriaViewModels>(categoria);

            return(View(categoriasViewmodel));
        }
예제 #2
0
        public ActionResult Delete(CategoriaViewModels categoria)
        {
            App_Start.AutoMapperWebConfiguration.Configure();
            dtoCategoria dtoCategoria = Mapper.Map <CategoriaViewModels, dtoCategoria>(categoria);

            var bllCategoria = new dtoCategoria();

            bllCategoria.Eliminar(dtoCategoria);

            return(RedirectToAction("Index"));
        }
예제 #3
0
        //
        // GET: /Categoria/
        public ActionResult Index(int?page)
        {
            var bllCategoria = new dtoCategoria();
            var categorias   = bllCategoria.TraerCategorias();

            App_Start.AutoMapperWebConfiguration.Configure();

            var categoriasViewmodel = Mapper.Map <List <CategoriaViewModels> >(categorias);

            var pageNumber = page ?? 1; // if no page was specified in the querystring, default to the first page (1)

            return(View(categoriasViewmodel.ToPagedList(pageNumber, 9)));
        }
예제 #4
0
        public ActionResult Create(CategoriaViewModels categoria)
        {
            if (ModelState.IsValid)
            {
                var dtoCat = Mapper.Map <CategoriaViewModels, dtoCategoria>(categoria);

                dtoCat.Nombre = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(categoria.Nombre);

                var bllCategoria = new dtoCategoria();
                bllCategoria.Crear(dtoCat);

                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(categoria));
            }
        }
예제 #5
0
        public ActionResult Update(CategoriaViewModels categoria)
        {
            if (ModelState.IsValid)
            {
                App_Start.AutoMapperWebConfiguration.Configure();
                dtoCategoria dtoCat = Mapper.Map <CategoriaViewModels, dtoCategoria>(categoria);

                dtoCat.Nombre = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(categoria.Nombre);

                var bllCategoria = new dtoCategoria();
                bllCategoria.Actualizar(dtoCat);

                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(categoria));
            }
        }