public void AddToCart(Pet pet)
        {
            // Get the matching cart and pet instances
            var cartItem = storeDB.Carts.SingleOrDefault(c => c.CartID == ShoppingCartID && c.PetID == pet.PetID);

            if (cartItem == null)
            {
                // Create a new cart item if no cart item exists
                cartItem = new Cart
                {
                    PetID = pet.PetID,
                    CartID = ShoppingCartID,
                    Count = 1,
                    DateCreated = DateTime.Now
                };

                storeDB.Carts.Add(cartItem);
            }
            else
            {
                // If the item does exist in the cart, then add one to the quantity
                cartItem.Count++;
            }

            // Save changes
            storeDB.SaveChanges();
        }
        public ActionResult Create(Pet pet)
        {
            if (ModelState.IsValid)
            {
                db.Pets.Add(pet);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.KindID = new SelectList(db.Kinds, "KindID", "Name", pet.KindID);
            ViewBag.CompanyID = new SelectList(db.Companies, "CompanyID", "Name", pet.CompanyID);
            return View(pet);
        }
 public ActionResult Edit(Pet pet)
 {
     if (ModelState.IsValid)
     {
         db.Entry(pet).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.KindID = new SelectList(db.Kinds, "KindID", "Name", pet.KindID);
     ViewBag.CompanyID = new SelectList(db.Companies, "CompanyID", "Name", pet.CompanyID);
     return View(pet);
 }