Пример #1
0
        public ActionResult MostrarProducto(Producto mimodelo, string cantidad, string numero)
        {
            BurritoContext db       = new BurritoContext();
            Producto       producto = db.Productos.Find(mimodelo.Id);
            var            data     = db.Database.SqlQuery <Ordenes>(
                @"SELECT * from dbo.Ordenes WHERE idComprador = @idComprador", new SqlParameter("@idComprador", User.Identity.GetUserId())).ToList();
            Ordenes orden = new Ordenes();

            orden.Cantidad    = int.Parse(cantidad);
            orden.idComprador = User.Identity.GetUserId();
            orden.Vendedor    = producto.Vendedor;
            orden.idVendedor  = producto.IdVendedor;
            orden.Producto    = producto.Nombre;
            orden.Estado      = "Nueva Orden";
            orden.Precio      = producto.Costo;
            orden.idProducto  = producto.Id;
            orden.FormadePago = "Efectivo";
            orden.TelCliente  = numero;
            if (orden.Cantidad > producto.Disponibles)
            {
                TempData["Message"] = "Nohaytantos";
                return(RedirectToAction("BurritosenVenta"));
            }
            db.Ordenes.Add(orden);
            db.SaveChanges();
            TempData["Message"] = "BurritoOrden";
            return(RedirectToAction("BurritosEnVenta"));
        }
Пример #2
0
        public ActionResult BurritosenVenta()
        {
            BurritoContext db   = new BurritoContext();
            var            data = db.Database.SqlQuery <Producto>(
                @"SELECT * from dbo.Productoes Where Disponibles >0").ToList();

            return(View(data));
        }
        public ActionResult RevisarHielera()
        {
            BurritoContext db       = new BurritoContext();
            String         vendedor = User.Identity.Name;
            var            data     = db.Database.SqlQuery <Producto>(
                @"SELECT * FROM dbo.Productoes 
                WHERE Vendedor = @Vendedor AND Disponibles>0", new SqlParameter("@Vendedor", vendedor)).ToList();

            return(View(data));
        }
Пример #4
0
        public ActionResult MostrarProducto(int id)
        {
            BurritoContext db       = new BurritoContext();
            Producto       producto = db.Productos.Find(id);

            if (producto != null)
            {
                //TempData["Message"] = "Exito";
                return(View(producto));
            }
            return(View());
        }
        public ActionResult MisOrdenes()
        {
            BurritoContext db   = new BurritoContext();
            var            data = db.Database.SqlQuery <Ordenes>(
                @"SELECT * FROM dbo.Ordenes 
                WHERE idVendedor = @idVendedor ", new SqlParameter("@idVendedor", User.Identity.GetUserId())).ToList();

            if (data != null)
            {
                return(View(data));
            }
            return(View());
        }
 public ActionResult AgregarProducto(Producto producto)
 {
     producto.IdVendedor = User.Identity.GetUserId();
     producto.Vendedor   = User.Identity.Name;
     //db.Entry(producto).State = EntityState.Modified;
     if (ModelState.IsValid)
     {
         BurritoContext db = new BurritoContext();
         db.Productos.Add(producto);
         db.SaveChanges();
         TempData["Message"] = "Agregado";
     }
     return(RedirectToAction("ListarProductos"));
 }
        public ActionResult RevisarHielera(List <Producto> a, IEnumerable <Burritos1.Models.Producto> Productos)
        {
            if (Request.Form["Actualizar Hielera"] != null)
            {
                List <string> listValues = new List <string>();
                foreach (string key in Request.Form.AllKeys)
                {
                    if (key.StartsWith("Disponibles"))
                    {
                        listValues.Add((Request.Form[key]));
                    }
                }
                string   cadena = listValues[0];
                string[] valores;
                valores = cadena.Split(',');

                BurritoContext db       = new BurritoContext();
                String         vendedor = User.Identity.Name;

                List <Producto> data = db.Database.SqlQuery <Producto>(
                    @"SELECT * FROM dbo.Productoes 
                    WHERE Vendedor = @Vendedor AND Disponibles>0", new SqlParameter("@Vendedor", vendedor)).ToList();
                for (int i = 0; i < data.Count(); i++)
                {
                    data[i].Disponibles     = int.Parse(valores[i]);
                    db.Entry(data[i]).State = EntityState.Modified;
                    db.SaveChanges();
                }
            }
            else
            {
                if (Request.Form["Vaciar Hielera"] != null)
                {
                    BurritoContext db       = new BurritoContext();
                    String         vendedor = User.Identity.Name;

                    List <Producto> data = db.Database.SqlQuery <Producto>(
                        @"SELECT * FROM dbo.Productoes 
                    WHERE Vendedor = @Vendedor AND Disponibles>0", new SqlParameter("@Vendedor", vendedor)).ToList();
                    for (int i = 0; i < data.Count(); i++)
                    {
                        data[i].Disponibles     = 0;
                        db.Entry(data[i]).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                }
            }
            return(RedirectToAction("RevisarHielera"));
        }
        public ActionResult ListarProductos()
        {
            if (TempData["Message"] != null)
            {
                switch (TempData["Message"])
                {
                case "Modificado": ViewBag.SucessMessage = "Modificado"; break;

                case "Eliminado": ViewBag.SucessMessage = "Eliminado"; break;

                case "Agregado": ViewBag.SucessMessage = "Agregado"; break;

                default: ViewBag.SucessMessage = "Error"; break;
                }
            }
            BurritoContext db       = new BurritoContext();
            String         vendedor = User.Identity.Name;
            var            data     = db.Database.SqlQuery <Producto>(
                @"SELECT * FROM dbo.Productoes 
                WHERE Vendedor = @Vendedor", new SqlParameter("@Vendedor", vendedor)).ToList();

            return(View(data));
        }