public ActionResult DeleteConfirmed(int id)
        {
            ComboRestaurante comboRestaurante = db.ComboRestaurantes.Find(id);

            db.ComboRestaurantes.Remove(comboRestaurante);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "IdComboRestaurante,IdRestaurante,Nombre,Descripcion,Precio,Imagen")] ComboRestaurante comboRestaurante)
 {
     if (ModelState.IsValid)
     {
         db.Entry(comboRestaurante).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IdRestaurante = new SelectList(db.Restaurantes, "IdRestaurante", "Nombre", comboRestaurante.IdRestaurante);
     return(View(comboRestaurante));
 }
Exemplo n.º 3
0
        public void AddToCart(ComboRestaurante combo)
        {
            // Get the matching cart and album instances
            var cartItem = db.Carts.SingleOrDefault(
                c => c.CartId == ShoppingCartId &&
                c.IdComboRestaurante == combo.IdComboRestaurante);

            if (cartItem == null)
            {
                // Create a new cart item if no cart item exists
                cartItem = new Cart
                {
                    IdComboRestaurante = combo.IdComboRestaurante,
                    CartId             = ShoppingCartId,
                    Cantidad           = 1,
                    FechaCreacion      = DateTime.Now
                                         //,RecordId = null
                };
                db.Carts.Add(cartItem);
            }
            else
            {
                // If the item does exist in the cart,
                // then add one to the quantity
                cartItem.Cantidad++;
            }



            try
            {
                // Your code...
                // Could also be before try if you know the exception occurs in SaveChanges


                // Save changes
                db.SaveChanges();
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }
        }
        // GET: AdministradorComboRestaurantes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ComboRestaurante comboRestaurante = db.ComboRestaurantes.Find(id);

            if (comboRestaurante == null)
            {
                return(HttpNotFound());
            }
            return(View(comboRestaurante));
        }
        // GET: AdministradorComboRestaurantes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ComboRestaurante comboRestaurante = db.ComboRestaurantes.Find(id);

            if (comboRestaurante == null)
            {
                return(HttpNotFound());
            }
            ViewBag.IdRestaurante = new SelectList(db.Restaurantes, "IdRestaurante", "Nombre", comboRestaurante.IdRestaurante);
            return(View(comboRestaurante));
        }
Exemplo n.º 6
0
 public void UpdateComboRestaurante(ComboRestaurante comboRestaurante)
 {
     context.Entry(comboRestaurante).State = EntityState.Modified;
 }
Exemplo n.º 7
0
        public void DeleteComboRestaurante(int comboRestauranteID)
        {
            ComboRestaurante comboRestaurante = context.ComboRestaurantes.Find(comboRestauranteID);

            context.ComboRestaurantes.Remove(comboRestaurante);
        }
Exemplo n.º 8
0
 public void InsertComboRestaurante(ComboRestaurante comboRestaurante)
 {
     context.ComboRestaurantes.Add(comboRestaurante);
 }