public void AddToCart(Guitar guitar) { Cart cart = _db.Carts.SingleOrDefault( c => c.Tag == ShoppingCartId && c.GuitarId == guitar.Id); if (cart == null) { cart = new Cart { GuitarId = guitar.Id, Tag = ShoppingCartId, Count = 1, DateCreated = DateTime.Now }; _db.Carts.Add(cart); } else { cart.Count++; } _db.SaveChanges(); }
private void FillGuitarViewBag(Guitar g) { ViewBag.BrandId = new SelectList(db.Brands, "Id", "Name", g.BrandId); ViewBag.ColorId = new SelectList(db.Colors, "Id", "Name", g.ColorId); ViewBag.ManufacturerId = new SelectList(db.Manufacturers, "Id", "Name", g.ManufacturerId); ViewBag.BodyWoodId = new SelectList(db.Woods, "WoodId", "Name", g.BodyWoodId); ViewBag.FretboardWoodId = new SelectList(db.Woods, "WoodId", "Name", g.FretboardWoodId); ViewBag.FingerboardWoodId = new SelectList(db.Woods, "WoodId", "Name", g.FingerboardWoodId); }
public ActionResult Edit(Guitar guitar) { if (ModelState.IsValid) { _db.Entry(guitar).State = EntityState.Modified; _db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.BrandId = new SelectList(_db.Brands, "Id", "Name", guitar.BrandId); ViewBag.ColorId = new SelectList(_db.Colors, "Id", "Name", guitar.ColorId); ViewBag.ManufacturerId = new SelectList(_db.Manufacturers, "ManufacturerId", "Name", guitar.ManufacturerId); return View(guitar); }
public NavigationMenuViewModel(Guitar currentGuitar, IEnumerable<BrandInfo> brandsInfo) { CurrentGuitar = currentGuitar; BrandsInfo = brandsInfo; }