Ejemplo n.º 1
0
        // 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));
            }
        }
Ejemplo n.º 2
0
        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));
            }
        }
Ejemplo n.º 3
0
        // 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);
            
        }
Ejemplo n.º 4
0
        // 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));
        }
Ejemplo n.º 5
0
        // GET: Cerveza/Delete/5
        public ActionResult Delete(int id)
        {
            CervezaViewModel usu = null;

            SessionInitialize();
            CervezaEN usuEN = new CervezaCAD(session).ReadOIDDefault(id);

            usu = new AssemblerCerveza().ConvertENToModelUI(usuEN);
            SessionClose();
            return(View(usu));
        }
Ejemplo n.º 6
0
        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));
        }
Ejemplo n.º 7
0
        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());
            }
        }
Ejemplo n.º 8
0
        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();
             * }*/
        }