Esempio n. 1
0
 public ReviewVM(review review,order order)
 {
     this.is_anonymous = false;
     this.review = review;
     this.review_order_items = new List<review_order_item>();
     this.order = order;
     createReviewOrderItemList(order);
 }
Esempio n. 2
0
        public static void MyClassInitialize(TestContext testContext)
        {
            touch_for_foodEntities db = new touch_for_foodEntities();
            m_review = new review();
            m_review.restaurant_id = db.restaurants.First().id;
            m_review.rating = 1;
            m_review.is_anonymous = true;

            db.reviews.Add(m_review);
            db.SaveChanges();
            db.Dispose();
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public static void MyClassInitialize(TestContext testContext)
        {
            testDatabase = new TestDatabaseHelper();

            //Add test data (order specific)
            item1 = testDatabase.AddItem();
            category1 = testDatabase.AddCategory();
            restaurant1 = testDatabase.AddRestaurant();
            menu1 = testDatabase.AddMenu(restaurant1);
            menuCategory1 = testDatabase.AddMenuCategory(category1, menu1);
            table1 = testDatabase.AddTable(restaurant1);
            order1 = testDatabase.AddOrder(table1);
            user1 = testDatabase.AddUser("*****@*****.**", table1, (int)SiteRoles.Admin);
            review1 = testDatabase.AddReview(restaurant1, order1, user1);
        }
Esempio n. 5
0
        public void MyTestInitialize()
        {
            //Add test data (order specific)
            restaurant1 = testDatabase.AddRestaurant();
            restaurant2 = new restaurant();
            table1 = testDatabase.AddTable(restaurant1);
            user1 = testDatabase.AddUser("*****@*****.**", table1, (int)SiteRoles.Admin);
            restaurantUser1 = testDatabase.AddRestaurantUser(user1, restaurant1);
            menu1 = testDatabase.AddMenu(restaurant1);
            order1 = testDatabase.AddOrder(table1);
            review1 = testDatabase.AddReview(restaurant1, order1, user1);

            //Session
            db = new touch_for_foodEntities();
            target = new RestaurantController();
            Session session = new Session(db, target);
            session.simulateLogin(user1.username, user1.password);
        }
Esempio n. 6
0
 public void MyTestInitialize()
 {
     review1 = testDatabase.AddReview(restaurant1, order1, user1);
     reviewItem1 = testDatabase.AddReviewOrderItem(review1, orderItem1, "rexiewTest", 1);
 }
Esempio n. 7
0
 /// <summary>
 /// Writes a review object to the database
 /// </summary>
 /// <param name="review">The review object to write</param>
 /// <returns>True if successful, false otherwise</returns>
 public bool Create(review review)
 {
     db.reviews.Add(review);
     return (db.SaveChanges() == 1);
 }
Esempio n. 8
0
 /// <summary>
 /// Writes a review object to the database associated with a user
 /// </summary>
 /// <param name="review">The review object to write</param>
 /// <param name="user">The user to associate the review with</param>
 /// <returns>True if successful, false otherwise</returns>
 public bool Create(review review, user user)
 {
     review.user_id = user.id;
     return Create(review);
 }
Esempio n. 9
0
 /// <summary>
 /// Removes a review item from the database.
 /// </summary>
 /// <param name="userEntity">The review to be removed.</param>
 public void RemoveReview(review reviewEntity)
 {
     db = new touch_for_foodEntities();
     if (db.reviews.Find(reviewEntity.id) != null)
     {
         db.reviews.Remove(db.reviews.Find(reviewEntity.id));
         db.SaveChanges();
     }
     db.Dispose();
 }
Esempio n. 10
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;
        }
Esempio n. 11
0
        /// <summary>
        /// Creates an entry of type review in the database.
        public review AddReview(restaurant r, order o, user u)
        {
            //Initialise
            db = new touch_for_foodEntities();
            review testReview = new review();

            //Set attributes
            testReview.is_anonymous = false;
            testReview.order_id = o.id;
            testReview.restaurant_id = r.id;
            testReview.user_id = u.id;
            testReview.rating = 0;

            //Save
            db.reviews.Add(testReview);
            db.SaveChanges();
            db.Dispose();

            return testReview;
        }
Esempio n. 12
0
 public ActionResult Edit(review review)
 {
     if (ModelState.IsValid)
     {
         db.Entry(review).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.order_id = new SelectList(db.orders, "id", "id", review.order_id);
     ViewBag.restaurant_id = new SelectList(db.restaurants, "id", "name", review.restaurant_id);
     ViewBag.user_id = new SelectList(db.users, "id", "username", review.user_id);
     return View(review);
 }