Exemplo n.º 1
0
 public int Create(review_order_item roi)
 {
     if(roi.rating == null)
     {
         roi.rating = 1;
     }
     db.review_order_item.Add(roi);
     return db.SaveChanges();
 }
Exemplo n.º 2
0
 /// <summary>
 /// for each order item in the order, create a place holder in the review order items
 /// </summary>
 /// <param name="order"></param>
 private void createReviewOrderItemList(order order)
 {
     foreach (order_item oi in order.order_item)
     {
         if (oi.review_order_item.Count == 0)
         {
             review_order_item roi = new review_order_item();
             roi.order_item = oi;
             roi.order_item_id = oi.id;
             review_order_items.Add(roi);
         }
     }
 }
Exemplo n.º 3
0
        public ActionResult Create(review_order_item review_order_item)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    db.review_order_item.Add(review_order_item);
                    db.SaveChanges();
                    return RedirectToAction("Index");
                }
                catch (Exception) { }
            }

            ViewBag.Error = Global.ServerError;
            ViewBag.order_item_id = new SelectList(db.order_item, "id", "note", review_order_item.order_item_id);
            ViewBag.review_id = new SelectList(db.reviews, "id", "id", review_order_item.review_id);
            return View(review_order_item);
        }
Exemplo n.º 4
0
        public void MyTestInitialize()
        {
            //Add test data (order specific)
            db = new touch_for_foodEntities();
            menuItem1 = testDatabase.AddMenuItem(item1, menuCategory1);
            orderItem1 = testDatabase.AddOrderItem(order1, menuItem1);
            reviewOrderItem1 = testDatabase.AddReviewOrderItem(review1, orderItem1, "testing1", 2);
            reviewOrderItem2 = testDatabase.AddReviewOrderItem(review1, orderItem1, "testing2", 3);

            //set parameters for menuItem2
            menuItem2 = new menu_item();
            menuItem2.item_id = item1.id;
            menuItem2.menu_category_id = menuCategory1.id;
            menuItem2.price = new decimal(10.99);
            menuItem2.is_active = false;
            menuItem2.is_deleted = false;
        }
Exemplo n.º 5
0
 public ActionResult Edit(review_order_item review_order_item)
 {
     if (ModelState.IsValid)
     {
         db.Entry(review_order_item).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.order_item_id = new SelectList(db.order_item, "id", "note", review_order_item.order_item_id);
     ViewBag.review_id = new SelectList(db.reviews, "id", "id", review_order_item.review_id);
     return View(review_order_item);
 }
Exemplo n.º 6
0
 public void MyTestInitialize()
 {
     review1 = testDatabase.AddReview(restaurant1, order1, user1);
     reviewItem1 = testDatabase.AddReviewOrderItem(review1, orderItem1, "rexiewTest", 1);
 }
Exemplo n.º 7
0
 public void RemoveReviewOrderItem(review_order_item reviewEntityOI)
 {
     db = new touch_for_foodEntities();
     if (db.review_order_item.Find(reviewEntityOI.id) != null)
     {
         db.review_order_item.Remove(db.review_order_item.Find(reviewEntityOI.id));
         db.SaveChanges();
     }
     db.Dispose();
 }
Exemplo n.º 8
0
        public review_order_item AddReviewOrderItem(review r, order_item oi, string text, int rating)
        {
            //Initialise
            db = new touch_for_foodEntities();
            review_order_item testReviewOI = new review_order_item();

            //Set attributes
            testReviewOI.rating = rating;
            testReviewOI.order_item_id = oi.id;
            testReviewOI.review_id = r.id;
            testReviewOI.submitted_on = System.DateTime.Now;
            testReviewOI.rating = 0;

            //Save
            db.review_order_item.Add(testReviewOI);
            db.SaveChanges();
            db.Dispose();

            return testReviewOI;
        }