public ActionResult OrderCreate([Bind(Include = "Id,CustomerName,CustomerPhone,CustomerEmail,CustomerAddress,PaymentMethod,TotalPrice,DiscountId,PaymentStatus")] Order orders) { if (ModelState.IsValid) { orders.Status = EOrderStatus.Received; orders.CreatedAt = DateTime.Now; db.Orders.Add(orders); db.SaveChanges(); return(RedirectToAction("Order")); } ViewBag.DiscountId = new SelectList(db.Discounts, "Id", "Code", orders.DiscountId); return(View("~/Views/AdminOrder/Create.cshtml", orders)); }
// GET: Admin/OrderDetails/5 public ActionResult OrderDetails(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Order orders = db.Orders.Find(id); if (orders == null) { return(HttpNotFound()); } return(View("~/Views/AdminOrder/Details.cshtml", orders)); }
// GET: AdminOrder/Edit/5 public ActionResult OrderEdit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Order orders = db.Orders.Find(id); if (orders == null) { return(HttpNotFound()); } ViewBag.DiscountId = new SelectList(db.Discounts, "Id", "Code", orders.DiscountId); return(View("~/Views/AdminOrder/Edit.cshtml", orders)); }
// GET: AdminOrder/Delete/5 public ActionResult OrderDelete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Order orders = db.Orders.Find(id); if (orders == null) { return(HttpNotFound()); } orders.Status = EOrderStatus.Cancelled; orders.DeletedAt = DateTime.Now; db.Entry(orders).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Order")); }
public ActionResult OrderEdit([Bind(Include = "Id,CustomerName,CustomerPhone,CustomerEmail,CustomerAddress,PaymentMethod,TotalPrice,DiscountId,Status,PaymentStatus,CreatedAt")] Order orders) { if (ModelState.IsValid) { orders.UpdatedAt = DateTime.Now; if (orders.Status == EOrderStatus.Cancelled) { orders.DeletedAt = DateTime.Now; } else { orders.DeletedAt = null; } db.Entry(orders).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Order")); } ViewBag.DiscountId = new SelectList(db.Discounts, "Id", "Code", orders.DiscountId); return(View("~/Views/AdminOrder/Edit.cshtml", orders)); }