Exemple #1
0
        // GET: Inicio
        public ActionResult Index()
        {
            var productos     = CNTienda.ObtenerProductos();
            var categorias    = CNTienda.ObtenerCategorias();
            var subCategorias = CNTienda.ObtenerSubcategorias();

            var modelo = new ViewModel();

            modelo.Productos = productos.Select(x => new Producto
            {
                IdProducto  = x.IdProducto,
                Nombre      = x.Nombre,
                Precio      = x.Precio,
                UrlImagen   = x.UrlImagen,
                EsOferta    = x.EsOferta,
                EsDestacado = x.EsDestacado
            }).ToList();

            modelo.Categorias = categorias.Select(x => new Categoria
            {
                IdCategoria  = x.IdCategoria,
                Nombre       = x.Nombre,
                SubCategoria = x.SubCategoria
            }).ToList();

            modelo.SubCategorias = subCategorias.Select(x => new SubCategoria
            {
                IdSubCategoria = x.IdSubCategoria,
                IdCategoria    = x.IdCategoria,
                Nombre         = x.Nombre
            }).ToList();

            return(View(modelo));
        }
        public ActionResult Index(string Nombre, string Correo, string Asunto, string Mensaje)
        {
            var respuesta = CNTienda.RealizarConsulta(Nombre, Correo, Asunto, Mensaje);

            if (respuesta)
            {
                ViewBag.Message = "Se envió el formulario Correctamente";
            }
            else
            {
                ViewBag.Message = "Por favor, revise los campos e intente nuevamente";
            }
            return(Json(data: new { respuesta = ViewBag.Message }, JsonRequestBehavior.AllowGet));
        }