// GET: HomeUsuario public ActionResult Index() { SessionInitialize(); SliderCAD sliCAD = new SliderCAD(session); SliderCEN sliCEN = new SliderCEN(sliCAD); IList <SliderEN> listSliEN = sliCEN.MuestraSliders(0, -1); IEnumerable <Slider> lista = new AssemblerSlider().ConvertListENToModel(listSliEN).ToList(); SessionClose(); SessionInitialize(); ProductoCAD cadArt = new ProductoCAD(session); CategoriaCAD cadCat = new CategoriaCAD(session); ProductoCEN cen = new ProductoCEN(cadArt); IList <ProductoEN> listProdEn = cen.MuestraProductos(0, -1); //DameProductosPorCat(id); Falta implementar este hql IEnumerable <Producto> listProds = new AssemblerProducto().ConvertListENToModel(listProdEn).ToList(); //CategoriaEN catEN = cadCat.ReadOIDDefault(id); SessionClose(); SessionInitialize(); IEnumerable <Producto> listprods2 = new AssemblerProducto().ConvertListENToModel(new ProductoCEN(new ProductoCAD(session)).GetTopVentas()); //GetProductosByNombre(Convert.ToString(form["prod"]), 0, -1)); SessionClose(); var tuple2 = Tuple.Create(lista, listProds, listprods2); return(View(tuple2)); }
// GET: Articulo/Details/5 public ActionResult Details(int id) { SessionInitialize(); ProductoCAD cad = new ProductoCAD(session); ProductoCEN cen = new ProductoCEN(cad); ProductoEN en = cen.ReadOID(id); AssemblerProducto ass = new AssemblerProducto(); Producto sol = ass.ConvertENToModelUI(en); IList <ComentarioEN> ten = en.Comentario; AssemblerComentario assc = new AssemblerComentario(); IList <Comentario> solc = assc.ConvertListENToModel(ten); SessionClose(); System.Web.HttpContext.Current.Session["comen"] = id; // ViewData["action"] = "Details"; ViewBag.coment = solc; return(View(sol)); }
// GET: HomeUsuario/PorCategoria/ public ActionResult PorCategoria(int id) { SessionInitialize(); IEnumerable <Producto> listprod = new AssemblerProducto().ConvertListENToModel(new ProductoCEN(new ProductoCAD(session)).GetProductosByCategoriaId(id, 0, -1)); SessionClose(); return(View(listprod)); }
// GET: Producto/Details/5 public ActionResult Details(int id) { Producto prod = null; SessionInitialize(); ProductoEN prodEN = new ProductoCAD(session).ReadOIDDefault(id); prod = new AssemblerProducto().ConvertENToModelUI(prodEN); SessionClose(); return(View(prod)); }
// GET: Articulo/Create public ActionResult Create() { ProductoEN en = new ProductoEN(); AssemblerProducto ass = new AssemblerProducto(); Producto sol = ass.ConvertENToModelUI(en); ViewData["controller"] = System.Web.HttpContext.Current.Session["controller"] as String; ViewData["action"] = System.Web.HttpContext.Current.Session["action"] as String; ViewData["arg"] = System.Web.HttpContext.Current.Session["arg"]; return(View(sol)); }
// GET: Producto //[Authorize] quien este autorizado podrá acceder //GARANTIZAR 100% //[AllowAnonymous] -> asegura que una persona anónima puede acceder public ActionResult Index(/*int id*/) { SessionInitialize(); ProductoCAD cadArt = new ProductoCAD(session); CategoriaCAD cadCat = new CategoriaCAD(session); ProductoCEN cen = new ProductoCEN(cadArt); IList <ProductoEN> listProdEn = cen.MuestraProductos(0, -1); //DameProductosPorCat(id); Falta implementar este hql IEnumerable <Producto> listProds = new AssemblerProducto().ConvertListENToModel(listProdEn).ToList(); //CategoriaEN catEN = cadCat.ReadOIDDefault(id); SessionClose(); return(View(listProds)); }
public ActionResult Index(FormCollection form) { try { SessionInitialize(); IEnumerable <Producto> listprods = new AssemblerProducto().ConvertListENToModel(new ProductoCEN(new ProductoCAD(session)).GetProductosByNombreStock(Convert.ToString(form["prod"]))); SessionClose(); return(View(listprods)); } catch { return(View()); } }
// GET: Articulo public ActionResult Index() { ProductoCEN cen = new ProductoCEN(); IList <ProductoEN> enlinst = cen.ReadAll(0, int.MaxValue); AssemblerProducto ass = new AssemblerProducto(); IList <Producto> listart = ass.ConvertListENToModel(enlinst); //articuloAsembler.covert System.Web.HttpContext.Current.Session["controller"] = "Producto"; System.Web.HttpContext.Current.Session["action"] = "Index"; System.Web.HttpContext.Current.Session["arg"] = null; return(View(listart)); }
public ActionResult Filtrar(FiltroProducto collection) { try { ProductoCEN cen = new ProductoCEN(); IList <ProductoEN> res = null, aux = null; // TODO: Add delete logic here res = cen.ReadAll(0, int.MaxValue); if (!(collection.Preciobol == false || collection.Preciomin <= 0 || collection.Preciomax <= 0 || collection.Preciomax <= collection.Preciomin)) { aux = cen.Filtroprecio(collection.Preciomin, collection.Preciomax); res = res.Intersect(aux).ToList(); } if (collection.Nombrebol == true && collection.Nombre != null) { aux = cen.Filtronombre(collection.Nombre); res = res.Intersect(aux).ToList(); } if (collection.tallabol == true && collection.Talla != null) { aux = cen.Filtrotalla(collection.Talla); res = res.Intersect(aux).ToList(); } if (collection.Valoracionbol == true && collection.Valoracion > 0 && collection.Valoracion < 6) { aux = cen.Filtrovalor((SMPGenNHibernate.Enumerated.SMP.ValoracionEnum)collection.Valoracion); res = res.Intersect(aux).ToList(); } AssemblerProducto ass = new AssemblerProducto(); IList <Producto> listart = ass.ConvertListENToModel(res); System.Web.HttpContext.Current.Session["resu"] = listart; return(RedirectToAction("Resultadobusqueda", "Producto", null)); // return View("Resultadobusqueda", listart); } catch { return(View()); } }
// GET: HomeUsuario/Details/5 public ActionResult Details(int id) { Producto prod = null; SessionInitialize(); ProductoEN prodEN = new ProductoCAD(session).ReadOIDDefault(id); prod = new AssemblerProducto().ConvertENToModelUI(prodEN); SessionClose(); SessionInitialize(); IEnumerable <Comentario> listcoms = new AssemblerComentario().ConvertListENToModel(new ComentarioCEN(new ComentarioCAD(session)).GetAllComentariosByProducto(id, 0, 10)); //GetProductosByNombre(Convert.ToString(form["prod"]), 0, -1)); SessionClose(); var tuple2 = Tuple.Create(prod, listcoms); return(View(tuple2)); }
public ActionResult BusquedaPost(string nombre) { try { SessionInitialize(); ProductoCAD pCAD = new ProductoCAD(session); ProductoCEN pCEN = new ProductoCEN(pCAD); AssemblerProducto assemblerProducto = new AssemblerProducto(); IList <ProductoEN> listaP = pCEN.BuscarProducto(nombre); IList <Producto> Return = assemblerProducto.ConvertListENToModel(listaP, session); SessionClose(); return(View(Return)); } catch { return(View()); } }
public ActionResult IndexDel() { SessionInitialize(); ProductoCEN pred = new ProductoCEN(new ProductoCAD()); IList <ProductoEN> predEn = pred.ReadAll(0, -1); IList <ProductoEN> definitiva = new List <ProductoEN>(); foreach (ProductoEN p in predEn) { if (!p.GetType().Name.Equals("PersonalizableEN")) { definitiva.Add(p); } } IEnumerable <Producto> list = new AssemblerProducto().ConvertListENToModel(definitiva, session).ToList(); SessionClose(); return(View(list)); }
public ActionResult Index(FormCollection form) { try { IEnumerable <Producto> listprods = null; switch (Convert.ToInt16(form["btn"])) { case 0: SessionInitialize(); listprods = new AssemblerProducto().ConvertListENToModel(new ProductoCEN(new ProductoCAD(session)).GetProductosByNombre(Convert.ToString(form["prod"]), 0, -1)); SessionClose(); break; case 1: SessionInitialize(); listprods = new AssemblerProducto().ConvertListENToModel(new ProductoCEN(new ProductoCAD(session)).GetProductosByPrecios(Convert.ToDouble(form["precio1"]), Convert.ToDouble(form["precio2"]))); SessionClose(); break; case 2: SessionInitialize(); listprods = new AssemblerProducto().ConvertListENToModel(new ProductoCEN(new ProductoCAD(session)).GetProductosByCategoria(Convert.ToString(form["categ"]))); SessionClose(); break; case 3: SessionInitialize(); listprods = new AssemblerProducto().ConvertListENToModel(new ProductoCEN(new ProductoCAD(session)).GetProductosBySuperCategoria(Convert.ToString(form["supcateg"]))); SessionClose(); break; } return(View(listprods)); } catch { return(View()); } }
public ActionResult Index() //Productos Agotados { SessionInitialize(); ProductoCAD cadArt = new ProductoCAD(session); CategoriaCAD cadCat = new CategoriaCAD(session); ProductoCEN cen = new ProductoCEN(cadArt); IList <ProductoEN> listProdEn = cen.MuestraProductos(0, -1); //DameProductosPorCat(id); Falta implementar este hql IList <ProductoEN> listAgotados = new List <ProductoEN>(); foreach (ProductoEN cosaProds in listProdEn) { if (cosaProds.Stock == 0) { listAgotados.Add(cosaProds); } } IEnumerable <Producto> listProds = new AssemblerProducto().ConvertListENToModel(listAgotados).ToList(); //CategoriaEN catEN = cadCat.ReadOIDDefault(id); SessionClose(); return(View(listProds)); }
public ActionResult TopVentasPost() { try { SessionInitialize(); ProductoCEN pred = new ProductoCEN(); IList <ProductoEN> list = pred.ReadAll(0, -1); List <ProductoEN> listica = new List <ProductoEN>(); foreach (ProductoEN p in list) { if (p.NumVeces != 0) { listica.Add(p); } } listica = listica.OrderByDescending(o => o.NumVeces).ToList(); IEnumerable <Producto> lista = new AssemblerProducto().ConvertListENToModel(listica, session).ToList(); SessionClose(); if (lista.Count() > 0) { return(View(lista)); } else { return(RedirectToAction("Index")); } } catch { return(View()); } }
// GET: Producto/Delete/5 public ActionResult Delete(int id) { try { // TODO: Add delete logic here int idCategoria = -1; SessionInitialize(); ProductoCAD prodCAD = new ProductoCAD(session); ProductoCEN cen = new ProductoCEN(prodCAD); ProductoEN prodEN = cen.MuestraProductoPorOID(id); Producto prod = new AssemblerProducto().ConvertENToModelUI(prodEN); idCategoria = prod.IdCategoria; SessionClose(); new ProductoCEN().Destroy(id); return(RedirectToAction("Index")); } catch { return(View()); } }
// GET: Articulo/Edit/5 public ActionResult Edit(int id) { ProductoCEN cen = new ProductoCEN(); ProductoEN en = new ProductoEN(); en = cen.ReadOID(id); // SessionInitializeTransaction(); //IProducto productoCAD = new productoCAD(session); // ProductoEN en = new Pro; AssemblerProducto ass = new AssemblerProducto(); Producto sol = ass.ConvertENToModelUI(en); ViewData["controller"] = System.Web.HttpContext.Current.Session["controller"] as String; ViewData["action"] = System.Web.HttpContext.Current.Session["action"] as String; ViewData["arg"] = System.Web.HttpContext.Current.Session["arg"]; return(View(sol)); }
// GET: HomeUsuario public ActionResult Index(string titulo, string categoria, string min, string max) { IList <Producto> salida = new List <Producto>(); if (String.IsNullOrEmpty(titulo) == false) { SessionInitialize(); salida = new AssemblerProducto().ConvertListENToModel(new ProductoCEN(new ProductoCAD(session)).GetProductosByNombre(titulo, 0, -1)); SessionClose(); } if (String.IsNullOrEmpty(min) == false || String.IsNullOrEmpty(max) == false) { if (String.IsNullOrEmpty(min)) { min = "0"; } if (String.IsNullOrEmpty(max)) { max = "99999999999"; } if (salida.Count <= 0) { SessionInitialize(); salida = new AssemblerProducto().ConvertListENToModel(new ProductoCEN(new ProductoCAD(session)).GetProductosByPrecios(Convert.ToDouble(min), Convert.ToDouble(max))); SessionClose(); } else { IList <Producto> aux = new List <Producto>(); foreach (var item in salida) { if (item.Precio >= Convert.ToDouble(min) && item.Precio <= Convert.ToDouble(max)) { aux.Add(item); } } salida = aux; } } if (String.IsNullOrEmpty(categoria) == false && categoria != "0") { if (salida.Count <= 0) { SessionInitialize(); salida = new AssemblerProducto().ConvertListENToModel(new ProductoCEN(new ProductoCAD(session)).GetProductosByCategoriaId(Convert.ToInt32(categoria), 0, -1)); SessionClose(); } else { IList <Producto> aux = new List <Producto>(); foreach (var item in salida) { if (item.IdCategoria == Convert.ToInt32(categoria)) { aux.Add(item); } } salida = aux; } } return(View(salida)); }