private void UpdateGridViews()
        {
            DataTable dt  = dbmngr.GetProductInfo(PNaam);
            DataTable dt2 = new DataTable();

            for (int i = 0; i <= dt.Rows.Count; i++)
            {
                dt2.Columns.Add();
            }
            for (int i = 0; i < dt.Columns.Count; i++)
            {
                dt2.Rows.Add();
                dt2.Rows[i][0] = dt.Columns[i].ColumnName;
            }
            for (int i = 0; i < dt.Columns.Count; i++)
            {
                for (int j = 0; j < dt.Rows.Count; j++)
                {
                    dt2.Rows[i][j + 1] = dt.Rows[j][i];
                }
            }
            ItemTable.DataSource = dt2;
            ItemTable.ShowHeader = false;
            ItemTable.DataBind();

            product        = dbmngr.GetProduct(PNaam);
            TitleProd.Text = product.Naam;

            PricesTable.DataSource = product.Prijzen;
            PricesTable.DataBind();

            ReviewTable.DataSource = product.Reviews;
            ReviewTable.DataBind();
        }
        public PartialViewResult AddReviews(int EventID, int classification, string review)
        {
            int userLog = Convert.ToInt32(User.Identity.GetUserId());

            if (ModelState.IsValid)
            {
                ReviewTable reviewTable = new ReviewTable
                {
                    EventID        = EventID,
                    UserID         = userLog,
                    Classification = classification,
                    Review         = review
                };

                db.ReviewTable.Add(reviewTable);
                db.Entry(reviewTable).State = EntityState.Added;
                db.SaveChanges();
            }

            EventTable eventTable = db.EventTable.Find(EventID);

            ViewBag.userLog     = userLog;
            ViewBag.userInEvent = eventTable.UserProfile1.Contains(db.UserProfile.Find(userLog));

            ViewBag.isOnReviews = true;

            return(PartialView("_ReviewsPartial", eventTable));
        }
        public void TestSaveItem()
        {
            var context = new Mock <IContext>();

            context.Setup(c => c.Environment).Returns("LOCAL");

            var db     = new ReviewTable(_dbClient, context.Object);
            var review = new Review
            {
                Id       = Guid.NewGuid(),
                Category = Category.Books,
                Author   = "Some guy on the internet",
                Text     = "The first of William Gibson\'s usually futuristic novels to be set in the present, Pattern Recognition is a masterful snapshot of modern consumer culture and hipster esoterica. Set in London, Tokyo, and Moscow, Pattern Recognition takes the reader on a tour of a global village inhabited by power-hungry marketeers, industrial saboteurs, high-end hackers, Russian mob bosses, Internet fan-boys, techno archeologists, washed-out spies, cultural documentarians, and our heroine Cayce Pollard--a soothsaying \"cool hunter\" with an allergy to brand names.",
                Book     = new Book()
                {
                    Author = "William Gibson",
                    Title  = "Pattern Recognition",
                    Genre  = "Science-Fiction",
                    Url    = "http://amazon.com",
                },
                Tags = new List <string>()
                {
                    "Science-Ficton", "Branding"
                }
            };

            db.SaveReview(review);
        }
        public void TestLikeItem()
        {
            var context = new Mock <IContext>();

            context.Setup(c => c.Environment).Returns("LOCAL");

            var db = new ReviewTable(_dbClient, context.Object);

            var result = db.GetReviews().ToList();

            result.Should().NotBeEmpty();

            var itemToFetch = result.First();

            var theFetchedItem = db.GetReview(itemToFetch.Category, itemToFetch.Id);

            theFetchedItem.Should().NotBeNull();

            var likes = theFetchedItem.Likes;

            db.LikeReview(theFetchedItem.Category, theFetchedItem.Id);
            // TODO: return the new number of likes?

            // may not be updated immediatley of course, but let's see...
            var theLikedItem = db.GetReview(itemToFetch.Category, itemToFetch.Id);

            theLikedItem.Should().NotBeNull();
            theLikedItem.Likes.Should().BeGreaterThan(likes);
        }
        public void TestGetItems()
        {
            var context = new Mock <IContext>();

            context.Setup(c => c.Environment).Returns("LOCAL");

            var db = new ReviewTable(_dbClient, context.Object);

            var result = db.GetReviews().ToList();

            result.Should().NotBeEmpty();

            var itemToFetch = result.First();

            var theFetchedItem = db.GetReview(itemToFetch.Category, itemToFetch.Id);

            theFetchedItem.Should().NotBeNull();

            var anotherItemToFecth = db.GetReview(Category.Apps, Guid.NewGuid());

            anotherItemToFecth.Should().BeNull();
        }
Esempio n. 6
0
 public ReviewsController(ReviewTable reviewTable)
 {
     _reviewTable = reviewTable;
 }