예제 #1
0
        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));
        }
예제 #2
0
        // 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));
        }
예제 #3
0
        // 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));
        }
예제 #4
0
        // 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"));
        }
예제 #5
0
        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));
        }