Beispiel #1
0
        public IActionResult Detail(int id)
        {
            var product = _context.products
                          //.Include(p => p.item)
                          .SingleOrDefault(p => p.ItemId == id);



            // .Select(ca => ca.category).ToList();

            if (product == null)
            {
                return(NotFound());
            }

            var Name = product.Name;

            var File = _context.Filess.Where(D => D.productName == Name).ToList();

            var Categoress = _context.products.Where(A => A.Id == id).SelectMany(s => s.categoryToProducts)
                             .Select(ca => ca.category).ToList();



            var pro = new AddDetailView()
            {
                product    = product,
                categories = Categoress,
                Filess     = File
            };

            return(View(pro));
        }
Beispiel #2
0
        public void TestAddDetailView()
        {
            AddDetailView   req;
            Request         req2;
            RecombeeBinding resp;

            // it 'does not fail with cascadeCreate'
            req  = new AddDetailView("u_id", "i_id", cascadeCreate: true);
            resp = client.Send(req);
            // it 'does not fail with existing item and user'
            req  = new AddDetailView("entity_id", "entity_id");
            resp = client.Send(req);
            // it 'does not fail with valid timestamp'
            req  = new AddDetailView("entity_id", "entity_id", timestamp: ParseDateTime("2013-10-29T09:38:41.341Z"));
            resp = client.Send(req);
            // it 'fails with nonexisting item id'
            req = new AddDetailView("entity_id", "nonex_id");
            try
            {
                client.Send(req);
                Assert.True(false, "No exception thrown");
            }
            catch (ResponseException ex)
            {
                Assert.Equal(404, (int)ex.StatusCode);
            }
            // it 'fails with nonexisting user id'
            req = new AddDetailView("nonex_id", "entity_id");
            try
            {
                client.Send(req);
                Assert.True(false, "No exception thrown");
            }
            catch (ResponseException ex)
            {
                Assert.Equal(404, (int)ex.StatusCode);
            }
            // it 'fails with invalid time'
            req = new AddDetailView("entity_id", "entity_id", timestamp: UnixTimeStampToDateTime(-15));
            try
            {
                client.Send(req);
                Assert.True(false, "No exception thrown");
            }
            catch (ResponseException ex)
            {
                Assert.Equal(400, (int)ex.StatusCode);
            }
            // it 'really stores interaction to the system'
            req  = new AddDetailView("u_id2", "i_id2", cascadeCreate: true, timestamp: UnixTimeStampToDateTime(5));
            resp = client.Send(req);
            try
            {
                client.Send(req);
                Assert.True(false, "No exception thrown");
            }
            catch (ResponseException ex)
            {
                Assert.Equal(409, (int)ex.StatusCode);
            }
        }