// GET: Cerveza public ActionResult Index(String data) { if (data != null) { CervezaCEN art = new CervezaCEN(); IList <CervezaEN> listaArticulos = art.ReadAll(0, -1).ToList(); IList <CervezaEN> listaArticulos2 = new List <CervezaEN>(); foreach (var item in listaArticulos) { if (item.Nombre.Contains(data)) { listaArticulos2.Add(item); } } IEnumerable <CervezaViewModel> list = new AssemblerCerveza().ConvertListENToModel(listaArticulos2).ToList(); return(View(list)); } else { CervezaCEN art = new CervezaCEN(); IList <CervezaEN> listaArticulos = art.ReadAll(0, -1).ToList(); IEnumerable <CervezaViewModel> list = new AssemblerCerveza().ConvertListENToModel(listaArticulos).ToList(); return(View(list)); } }
public ActionResult Buscar(String data) { if (data != null) { CervezaCEN art = new CervezaCEN(); IList <CervezaEN> listaArticulos = art.ReadAll(0, -1).ToList(); IList <CervezaEN> listaArticulos2 = new List <CervezaEN>(); foreach (var item in listaArticulos) { if (item.Nombre.ToLower().Contains(data.ToLower())) { System.Diagnostics.Debug.WriteLine("Añado: " + item.Nombre); listaArticulos2.Add(item); } } IEnumerable <CervezaViewModel> list = new AssemblerCerveza().ConvertListENToModel(listaArticulos2).ToList(); return(View(list)); } else { CervezaCEN art = new CervezaCEN(); IList <CervezaEN> listaArticulos = art.ReadAll(0, -1).ToList(); IEnumerable <CervezaViewModel> list = new AssemblerCerveza().ConvertListENToModel(listaArticulos).ToList(); return(View(list)); } }
public ActionResult Create(CervezaViewModel cerveza, HttpPostedFileBase file) { string fileName = "", path = ""; // Verify that the user selected a file if (file != null && file.ContentLength > 0) { System.Diagnostics.Debug.WriteLine("Entro en el if "); // extract only the fielname fileName = Path.GetFileName(file.FileName); System.Diagnostics.Debug.WriteLine(fileName); // store the file inside ~/App_Data/uploads folder path = Path.Combine(Server.MapPath("~/Content/IMG"), fileName); System.Diagnostics.Debug.WriteLine(path); //string pathDef = path.Replace(@"\\", @"\"); file.SaveAs(path); } try { fileName = "/Content/IMG/" + fileName; System.Diagnostics.Debug.WriteLine("Nombre: " + fileName); CervezaCEN art = new CervezaCEN(); art.New_(cerveza.Nombre, cerveza.Stock, cerveza.Precio, cerveza.ValMedia, cerveza.Descripcion, fileName, cerveza.Marca, cerveza.Volumen, cerveza.Unidades, cerveza.Graduacion, cerveza.Tipo); return(RedirectToAction("Index")); } catch { return(View()); } }
// GET: ArtVal/Details/5 public ActionResult Details(int id) { CervezaViewModel usu = null; IEnumerable<ValoracionViewModel> val = null; ArtValViewModel artVal = new ArtValViewModel(); CervezaCEN cerCEN = new CervezaCEN(); CervezaEN usuEN = cerCEN.ReadOID(id); ValoracionCEN valCEN = new ValoracionCEN(); usu = new AssemblerCerveza().ConvertENToModelUI(usuEN); IList<ValoracionEN> valEN = valCEN.ReadAll(0, -1).ToList(); IList<ValoracionEN> bueno = new List<ValoracionEN>(); foreach (var item in valEN) { if (item.Articulo.Id == id) { bueno.Add(item); } } usu = new AssemblerCerveza().ConvertENToModelUI(usuEN); val = new AssemblerValoracion().ConvertListENToModel(bueno).ToList(); artVal.cerveza = usu; artVal.valoraciones = val; return View(artVal); }
// GET: Cerveza public ActionResult Index() { CervezaCEN art = new CervezaCEN(); IList <CervezaEN> listaArticulos = art.ReadAll(0, -1).ToList(); IEnumerable <CervezaViewModel> list = new AssemblerCerveza().ConvertListENToModel(listaArticulos).ToList(); return(View(list)); }
public ActionResult Delete(CervezaViewModel articulo) { try { CervezaCEN art = new CervezaCEN(); art.Destroy(articulo.id); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(CervezaViewModel articulo) { try { CervezaCEN cen = new CervezaCEN(); cen.Modify(articulo.id, articulo.Nombre, articulo.Stock, articulo.Precio, articulo.ValMedia, articulo.Descripcion, articulo.Imagen, articulo.Marca, articulo.Volumen, articulo.Unidades, articulo.Graduacion, articulo.Tipo); return(RedirectToAction("Index", new { id = articulo.id })); } catch { return(View()); } }
public ActionResult Create(CervezaViewModel articulo) { try { CervezaCEN art = new CervezaCEN(); art.New_(articulo.Nombre, articulo.Stock, articulo.Precio, articulo.ValMedia, articulo.Descripcion, articulo.Imagen, articulo.Marca, articulo.Volumen, articulo.Unidades, articulo.Graduacion, articulo.Tipo); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult tramitar() { string id = Request.Cookies["id"].Value; string importe = Request.Cookies["coste"].Value; string mPago = Request.Cookies["mPago"].Value; string direccion = Request.Cookies["direccion"].Value; PedidoCEN pedidoCEN = new PedidoCEN(); int oid = pedidoCEN.New_(id, (CervezUAGenNHibernate.Enumerated.CervezUA.EstadoPedidoEnum) 1, Convert.ToDouble(importe), direccion, (CervezUAGenNHibernate.Enumerated.CervezUA.MetodoPagoEnum)Int32.Parse(mPago)); LineaPedidoCEN lineaCEN = new LineaPedidoCEN(); string lista = Request.Cookies["carrito"].Value; string[] listaAux = lista.Split(','); List <int> converted = new List <int>(); List <int> converted2 = new List <int>(); int control = 0; foreach (var item in listaAux) { if (control == 0) { var aux = item.Replace("[", "").Replace("]", "").Replace("\"", ""); System.Diagnostics.Debug.WriteLine("Añado: " + aux); converted.Add(Int32.Parse(aux)); control = 1; } else { var aux = item.Replace("[", "").Replace("]", "").Replace("\"", ""); System.Diagnostics.Debug.WriteLine("Añado: " + aux); converted2.Add(Int32.Parse(aux)); control = 0; } } CervezaCEN art = new CervezaCEN(); for (int i = 0; i < converted.Count(); i++) { lineaCEN.New_(converted2[i], art.ReadOID(converted[i]).Id, oid); CervezaEN cerveza = art.ReadOID(converted[i]); cerveza.Stock = (cerveza.Stock - converted2[i]); //Estoy quitando el stock, hay que probarlo art.Modify(cerveza.Id, cerveza.Nombre, cerveza.Stock, cerveza.Precio, cerveza.ValMedia, cerveza.Descripcion, cerveza.Imagen, cerveza.Marca, cerveza.Volumen, cerveza.Unidades, cerveza.Graduacion, cerveza.Tipo); } return(Redirect("/Pedido/Pedidos")); }
public ActionResult Lista(int id) { LineaPedidoCEN art = new LineaPedidoCEN(); IList <LineaPedidoEN> listaLin = art.ReadAll(0, -1).ToList(); IList <CervezaEN> converted = new List <CervezaEN>(); CervezaCEN cerv = new CervezaCEN(); foreach (var item in listaLin) { if (id == item.Pedido.Id) { converted.Add(cerv.ReadOID(item.Articulo.Id)); } } IEnumerable <CervezaViewModel> list = new AssemblerCerveza().ConvertListENToModel(converted).ToList(); return(View(list)); }
public ActionResult Carrito() { string lista = Request.Cookies["carrito"].Value; if (lista != "") { string[] listaAux = lista.Split(','); List <int> converted = new List <int>(); int control = 0; foreach (var item in listaAux) { if (control == 0) { var aux = item.Replace("[", "").Replace("]", "").Replace("\"", ""); System.Diagnostics.Debug.WriteLine("Añado: " + aux); converted.Add(Int32.Parse(aux)); control = 1; } else { control = 0; } } CervezaCEN art = new CervezaCEN(); IList <CervezaEN> listaArticulos = new List <CervezaEN>(); foreach (var item in converted) { listaArticulos.Add(art.ReadOID(item)); } IEnumerable <CervezaViewModel> list = new AssemblerCerveza().ConvertListENToModel(listaArticulos).ToList(); return(View(list)); } else { return(View()); } }
public ActionResult Comprar() { string lista = Request.Cookies["carrito"].Value; if (lista != "") { string[] listaAux = lista.Split(','); List <int> converted = new List <int>(); int control = 0; foreach (var item in listaAux) { if (control == 0) { var aux = item.Replace("[", "").Replace("]", "").Replace("\"", ""); System.Diagnostics.Debug.WriteLine("Añado: " + aux); converted.Add(Int32.Parse(aux)); control = 1; } else { control = 0; } } CervezaCEN art = new CervezaCEN(); IList <CervezaEN> listaArticulos = new List <CervezaEN>(); foreach (var item in converted) { listaArticulos.Add(art.ReadOID(item)); } IEnumerable <CervezaViewModel> list = new AssemblerCerveza().ConvertListENToModel(listaArticulos).ToList(); return(View(list)); } else { return(View()); } /* * SessionInitialize(); * string lista = Request.Cookies["carrito"].Value; * * if (lista != "") * { * string[] listaAux = lista.Split(','); * * List<int> converted = new List<int>(); * List<int> converted2 = new List<int>(); * int control = 0; * foreach (var item in listaAux) * { * if (control == 0) * { * var aux = item.Replace("[", "").Replace("]", "").Replace("\"", ""); * System.Diagnostics.Debug.WriteLine("Añado: " + aux); * converted.Add(Int32.Parse(aux)); * control = 1; * } * else * { * var aux = item.Replace("[", "").Replace("]", "").Replace("\"", ""); * System.Diagnostics.Debug.WriteLine("Añado: " + aux); * converted2.Add(Int32.Parse(aux)); * control = 0; * } * * } * CervezaCEN cerv = new CervezaCEN(); * IList<CervezaEN> listaArticulos = new List<CervezaEN>(); * IList<LineaPedidoEN> linea = new List<LineaPedidoEN>(); * System.Diagnostics.Debug.WriteLine("Antes for each"); * foreach (var item in converted) * { * * listaArticulos.Add(cerv.ReadOID(item)); * } * System.Diagnostics.Debug.WriteLine("Antes for for"); * for (int i = 0; i < converted.Count(); i++) * { * System.Diagnostics.Debug.WriteLine("Entro"); * LineaPedidoCEN lin = new LineaPedidoCEN(); * System.Diagnostics.Debug.WriteLine("Peto aqui"); * System.Diagnostics.Debug.WriteLine(converted2[i]+listaArticulos[i].Nombre); * int id = lin.New_(converted2[i], listaArticulos[i]); * System.Diagnostics.Debug.WriteLine("Peto aqui 2"); * * linea.Add(lin.ReadOID(id)); * System.Diagnostics.Debug.WriteLine("Peto aqui 3"); * * } * System.Diagnostics.Debug.WriteLine("Despues for "); * * string usuario = Request.Cookies["id"].Value; * UsuarioCAD usu = new UsuarioCAD(session); * UsuarioEN u = usu.ReadOIDDefault(usuario); * UsuarioCP usua = new UsuarioCP(session); * usua.Comprar(usuario, linea); * System.Diagnostics.Debug.WriteLine("Chorizo"); * * SessionClose(); * return View(listaArticulos); * } * else * { * return Redirect("/Cerveza/Carrito"); * } * ----------------------------------------------------------------- */ /* * string lista = Request.Cookies["carrito"].Value; * string usu = Request.Cookies["id"].Value; * * if (lista != "") * { * string[] listaAux = lista.Split(','); * * List<int> converted = new List<int>(); * List<int> converted2 = new List<int>(); * int control = 0; * foreach (var item in listaAux) * { * if (control == 0) * { * var aux = item.Replace("[", "").Replace("]", "").Replace("\"", ""); * System.Diagnostics.Debug.WriteLine("Añado: " + aux); * converted.Add(Int32.Parse(aux)); * control = 1; * } * else * { * var aux = item.Replace("[", "").Replace("]", "").Replace("\"", ""); * System.Diagnostics.Debug.WriteLine("Añado: " + aux); * converted2.Add(Int32.Parse(aux)); * control = 0; * control = 0; * } * * } * CervezaCEN art = new CervezaCEN(); * LineaPedidoCEN linea = new LineaPedidoCEN(); * PedidoCEN pedido = new PedidoCEN(); * IList<LineaPedidoEN> listaLineas = new List<LineaPedidoEN>(); * System.Diagnostics.Debug.WriteLine("Hasta qui bien"); * for (int i = 0; i < converted.Count(); i++) * { * System.Diagnostics.Debug.WriteLine("Entro"); * //LineaPedidoEN lin = linea.ReadOID(linea.New_(converted2[i], art.ReadOID(converted[i]))); * //listaLineas.Add(lin); * } * //pedido.New_(usu, (CervezUAGenNHibernate.Enumerated.CervezUA.EstadoPedidoEnum)1, listaLineas); * * return View(); * * }else * { * return View(); * }*/ }