public async Task <ActionResult> Edit([Bind(Include = "customerId,customerName,customerLastName,customerphoneNumber,customerCountry,customerCity")] Customer customer) { if (ModelState.IsValid) { db.Entry(customer).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.customerId = new SelectList(db.AspNetUsers, "Id", "Email", customer.customerId); ViewBag.customerCountry = new SelectList(db.Country, "countryName", "countryName", customer.customerCountry); return(View(customer)); }
public async Task <ActionResult> Edit([Bind(Include = "bundleId,bundleName,info,pic,price")] Bundle bundle) { if (ModelState.IsValid) { List <BundleInfo> oldBundle = await(from x in db.BundleInfos where x.bundleId == bundle.bundleId select x).ToListAsync <BundleInfo>(); List <BundleInfo> newBundle = (List <BundleInfo>)Session["BundleList"]; db.Entry(bundle).State = EntityState.Modified; await db.SaveChangesAsync(); foreach (BundleInfo item in oldBundle) { db.BundleInfos.Remove(item); } await db.SaveChangesAsync(); foreach (BundleInfo item in newBundle) { db.BundleInfos.Add(new BundleInfo() { bundleId = bundle.bundleId, productID = item.productID, quantity = item.quantity }); } await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(bundle)); }
public async Task <ActionResult> Edit(AlcoholProduct alcoholProduct) { if (ModelState.IsValid) { alcoholProduct.Product.productID = alcoholProduct.productID; db.Entry(alcoholProduct).State = EntityState.Modified; db.Entry(alcoholProduct.Product).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.categoryID = new SelectList(db.AlcoholCategory, "id", "categoryName", alcoholProduct.categoryID); ViewBag.origin = new SelectList(db.Country, "countryName", "countryName", alcoholProduct.origin); ViewBag.productID = new SelectList(db.Product, "productID", "productName", alcoholProduct.productID); return(View(alcoholProduct)); }
public async Task <ActionResult> Edit(CigaresProduct cigaresProduct) { if (ModelState.IsValid) { cigaresProduct.Product.productID = cigaresProduct.productID; db.Entry(cigaresProduct).State = EntityState.Modified; db.Entry(cigaresProduct.Product).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.cigarBrand = new SelectList(db.CigarBrands, "id", "brandName", cigaresProduct.cigarBrand); ViewBag.wrapperType = new SelectList(db.CigaresWrapper, "wrapperName", "wrapperName", cigaresProduct.wrapperType); ViewBag.strengthID = new SelectList(db.CigarStrengths, "id", "strengthName", cigaresProduct.strengthID); ViewBag.origin = new SelectList(db.Country, "countryName", "countryName", cigaresProduct.origin); ViewBag.productID = new SelectList(db.Product, "productID", "productName", cigaresProduct.productID); return(View(cigaresProduct)); }
public ActionResult Edit([Bind(Include = "id,username,name,password,address,email")] taikhoan taikhoan) { if (ModelState.IsValid) { db.Entry(taikhoan).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(taikhoan)); }
public ActionResult Edit([Bind(Include = "id,name,loai")] loaithutuc loaithutuc) { if (ModelState.IsValid) { db.Entry(loaithutuc).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(loaithutuc)); }
public async Task <ActionResult> Edit([Bind(Include = "id,brandName,pic")] CigarBrand cigarBrand) { if (ModelState.IsValid) { db.Entry(cigarBrand).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(cigarBrand)); }
public async Task <ActionResult> Edit([Bind(Include = "id,categoryName,pic")] AlcoholCategory alcoholCategory) { if (ModelState.IsValid) { db.Entry(alcoholCategory).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(alcoholCategory)); }
public async Task <ActionResult> CheckOut([Bind(Exclude = "creditCard")] CheckOut newHistory) { Cart myCart = (Cart)Session["Cart"]; if (myCart.myCart.Count == 0) { return(View("Index")); } if (ModelState.IsValid) { Session["Cart"] = null; DateTime today = DateTime.Now; AspNetUser user = await Utility.Util.getUser(HttpContext.User); newHistory.history.bh.userId = user.Id; newHistory.history.bh.buyingDate = today.ToString(); db.BuyingHistory.Add(newHistory.history.bh); await db.SaveChangesAsync(); BuyingHistory ttt = await db.BuyingHistory.OrderByDescending(i => i.buyingId).FirstOrDefaultAsync <BuyingHistory>(); BuyingHistoryItem historyItem; foreach (CartItem p in myCart.myCart) { historyItem = new BuyingHistoryItem(); historyItem.buyingId = ttt.buyingId; if (p.isBundle) { historyItem.productID = 1012; historyItem.bundleId = p.id; } else { historyItem.bundleId = 3; historyItem.productID = p.id; } historyItem.quantity = p.quantity; newHistory.history.bh.totalPrice += p.price * p.quantity; db.BuyingHistoryItems.Add(historyItem); } db.Entry(newHistory.history.bh).State = EntityState.Modified; await db.SaveChangesAsync(); //creditCard.card.userId = userId; return(RedirectToAction("Invoice", "BuyingHistories", new { id = ttt.buyingId })); } return(View(newHistory)); }
public async Task <ActionResult> Edit(CreditModelView creditCard) { AspNetUser user = await Utility.Util.getUser(HttpContext.User); Customer cust = await db.Customers.FindAsync(user.Id.ToString()); if (ModelState.IsValid) { creditCard.card.userId = cust.customerId; db.Entry(creditCard.card).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.userId = new SelectList(db.Customers, "customerId", "customerName", creditCard.card.userId); return(View(creditCard)); }