// GET: Order
 public ActionResult Add(int id)
 {
     if (Session["Order"] == null)
     {
         Order o = new Order();
         o.OrderDate = DateTime.Now;
         o.IsPay     = false;
         if (Session["CurrentUser"] != null)
         {
             Member m = (Member)Session["CurrentUser"];
             o.MemberID = m.UserID;
         }
         or.Insert(o);
         Session["Order"] = or.GetLatestObj(1).ProccessResult[0];
         OrderDetail od = new OrderDetail();
         od.OrderID   = ((Order)Session["Order"]).OrderID;
         od.ProductID = id;
         od.Quantity  = 1;
         od.Price     = pr.GetById(id).ProccessResult.Price;
         ordrep.Insert(od);
     }
     else
     {
         Order       o      = (Order)Session["Order"];
         OrderDetail update = ordrep.GetOrdByTwoId(o.OrderID, id).ProccessResult;
         if (update == null)
         {
             OrderDetail ord = new OrderDetail();
             ord.OrderID   = o.OrderID;
             ord.ProductID = id;
             ord.Quantity  = 1;
             ord.Price     = pr.GetById(id).ProccessResult.Price;
             ordrep.Insert(ord);
         }
         else
         {
             update.Quantity++;
             update.Price += pr.GetById(id).ProccessResult.Price;
             ordrep.Update(update);
         }
     }
     return(RedirectToAction("Index", "Home"));
 }
Exemple #2
0
        public ActionResult EditProduct(int id)
        {
            List <SelectListItem> CatList   = new List <SelectListItem>();
            List <SelectListItem> BrandList = new List <SelectListItem>();

            pwm.Product = pr.GetById(id).ProccessResult;
            BrandCatList(CatList, BrandList, (Guid)pwm.Product.CategoryID, (int)pwm.Product.BrandID);
            pwm.CategoryList = CatList;
            pwm.BrandList    = BrandList;
            return(View(pwm));
        }
Exemple #3
0
        public ActionResult Details(int id)
        {
            Product p = pr.GetById(id).ProccessResult;

            return(View(p));
        }