public ActionResult DeleteConfirmed(int id)
        {
            BuyProtein buyProtein = db.BuyProteins.Find(id);

            db.BuyProteins.Remove(buyProtein);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "BuyProteinId,ProteinId,FirstName,LastName,PhoneNumber,Country,Address,CreditCardNumber")] BuyProtein buyProtein)
 {
     if (ModelState.IsValid)
     {
         db.Entry(buyProtein).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(buyProtein));
 }
        public ActionResult Create(int id)
        {
            BuyProtein model = new BuyProtein();

            model.ProteinId = id;



            return(View(model));
        }
        public ActionResult Create(BuyProtein buyProtein)
        {
            if (ModelState.IsValid)
            {
                var protein = db.Proteins.Find(buyProtein.ProteinId);
                protein.NumberOfProductsInStock = protein.NumberOfProductsInStock - 1;
                db.BuyProteins.Add(buyProtein);
                db.SaveChanges();
                return(RedirectToAction("Index", "Proteins"));
            }

            return(View(buyProtein));
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BuyProtein buyProtein = db.BuyProteins.Find(id);

            if (buyProtein == null)
            {
                return(HttpNotFound());
            }
            return(View(buyProtein));
        }