public ActionResult DeleteConfirmed(string id) { Bill_new bill_new = db.Bill_new.Find(id); db.Bill_new.Remove(bill_new); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID_bill,ID,list,amount,total,addresz,SDt,name_bill")] Bill_new bill_new) { if (ModelState.IsValid) { db.Entry(bill_new).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ID = new SelectList(db.Users, "ID", "Email", bill_new.ID); return(View(bill_new)); }
// GET: Bill_new/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Bill_new bill_new = db.Bill_new.Find(id); if (bill_new == null) { return(HttpNotFound()); } return(View(bill_new)); }
// GET: Bill_new/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Bill_new bill_new = db.Bill_new.Find(id); if (bill_new == null) { return(HttpNotFound()); } ViewBag.ID = new SelectList(db.Users, "ID", "Email", bill_new.ID); return(View(bill_new)); }
//Thêm vào xác nhận thanh toán public ActionResult Deliver() { Users Users = (Users)Session["User"]; if (Users == null) { return(RedirectToAction("Login", "Home")); } else { var ListProduct = Services.ProductServices.GetProductViewModel(Users); Bill_new bill = new Bill_new(); bill.name_bill = Users.Email; double?tong = 0; foreach (var item in ListProduct) { tong += item.Total; } bill.total = tong; var tuple = new Tuple <Bill_new, List <ProductViewModel> >(bill, ListProduct); return(View(tuple)); } }
public ActionResult Deliver(FormCollection bill) { Users Users = (Users)Session["User"]; var isNumeric = long.TryParse(bill.GetValue(bill.GetKey(3)).AttemptedValue, out long n); if (isNumeric && bill.GetValue(bill.GetKey(3)).AttemptedValue.Length == 10) { if (Users == null) { return(RedirectToAction("Login", "Home")); } else { var ListProduct = Services.ProductServices.GetProductViewModel(Users); Bill_new bill_new = new Bill_new(); bill_new.name_bill = bill.GetValue(bill.GetKey(1)).AttemptedValue; bill_new.SDt = bill.GetValue(bill.GetKey(3)).AttemptedValue; bill_new.addresz = bill.GetValue(bill.GetKey(2)).AttemptedValue; bill_new.ID = Users.ID; var pd = context.Cart.Where(sx => sx.Users.Email.Equals(Users.Email)).FirstOrDefault(); bill_new.amount = pd.amount; bill_new.list = pd.list; var s = Services.IDServices.RandomIDBill(); var bills = context.Bill_new.Where(x => x.ID_bill.Equals(s)).FirstOrDefault(); while (bills != null) { s = Services.IDServices.RandomIDBill(); bills = context.Bill_new.Where(x => x.ID_bill.Equals(s)).FirstOrDefault(); } bill_new.ID_bill = s; double?tong = 0; foreach (var item in ListProduct) { tong += item.Total; } bill_new.total = tong; context.Bill_new.Add(bill_new); var Cart = context.Cart.Where(x => x.Users.Email == Users.Email).FirstOrDefault(); if (Cart != null) { context.Cart.Remove(Cart); } context.SaveChanges(); return(RedirectToAction("DeliverSucess")); } } else { ViewBag.PhoneNumber = "Số điện thoại không hợp lệ"; var ListProduct = Services.ProductServices.GetProductViewModel(Users); Bill_new billl = new Bill_new(); billl.name_bill = Users.Email; double?tong = 0; foreach (var item in ListProduct) { tong += item.Total; } billl.total = tong; var tuple = new Tuple <Bill_new, List <ProductViewModel> >(billl, ListProduct); return(View(tuple)); } }