Exemple #1
0
        //
        // GET: /Review/Create
        public ActionResult Create(int orderID)
        {
            ReviewVM reviewVM;
            review review = new review();
            OrderIM oim = new OrderIM(db);

            user authUser = Util.User.UserUtil.getAuthenticatedUser(Request);

            if (authUser == null)
            {
                return RedirectToAction("Index", "User");
            }
            review.user_id = authUser.id;

            // Look for a valid order before we continue
            order order = oim.find(orderID);
            if (order == null)
            {
                return RedirectToAction("Index", "User");
            }
            review.order_id = order.id;
            if (order.table != null)
            {
                review.restaurant_id = order.table.restaurant_id.Value;
            }
            else
            {
                //TODO: this must be fixed after CAP-480
                review.restaurant_id = db.restaurants.First().id;
            }
            reviewVM = new ReviewVM(review, order);
            Session.Add(Global.ReviewVMSession, reviewVM);
            ViewBag.ratings = new SelectList(Rating.GetRatings(), "Value", "Text");

            return View(reviewVM);
        }
Exemple #2
0
        public Boolean edit(order order)
        {
            OrderIM im = new OrderIM(db);
            order dbVersion = im.find(order.id);
            if (dbVersion.version == order.version)
            {
                ((IObjectContextAdapter)db).ObjectContext.Detach(dbVersion);
                db.Entry(order).State = EntityState.Modified;

                order.version = order.version + 1;
                db.SaveChanges();
                return true;
            }
            return false;
        }
Exemple #3
0
 private JsonResult GetOrderItemData(int orderID)
 {
     OrderIM oim = new OrderIM(db);
     order o = oim.find(orderID);
     List<order_item> orderItems = new List<order_item>();
     foreach (order_item oi in o.order_item)
     {
         orderItems.Add(oi);
     }
     return Json(orderItems);
 }