示例#1
0
        public void ServiceLayer_User_INF_Test()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <EfstoreContext>()
                          .UseInMemoryDatabase(databaseName: "WebstoreDB").Options;

            //ACT
            using (var op = new EfstoreContext(options))
            {
                userinformation sb = new userinformation();
                sb.id          = 1;
                sb.fullname    = "Hansen";
                sb.Address     = "Hansenvej 1";
                sb.dateofbirth = DateTime.Now;
                sb.CountryCode = 1100;
                sb.city        = "hansenberg";
                sb.gender      = "M";
                sb.paymentO    = "MasterCard";

                var PS = new UserinformationService(op);
                PS.Add(sb);

                //Assert
                // Use a separate instance of the context to verify correct data was saved to database
                using (var context = new EfstoreContext(options))
                {
                    Assert.AreEqual(1, context.userinformtation.Count());
                    Assert.AreEqual("hansenberg", context.userinformtation.Single().city);
                    Assert.AreNotEqual("ansenberg", context.userinformtation.Single().city);
                }

                {
                }
            }
        }
示例#2
0
        public void ServiceLayer_ShopBasket_INF_Test()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <EfstoreContext>()
                          .UseInMemoryDatabase(databaseName: "WebstoreDB").Options;

            //ACT
            using (var op = new EfstoreContext(options))
            {
                Shopbasket sb = new Shopbasket();
                sb.Product_id = 1;
                sb.Name       = "Adiddas";
                sb.OrderLines = "4";
                sb.Quantity   = 4;

                var PS = new ShopbasketService(op);
                PS.Add(sb);

                //Assert
                // Use a separate instance of the context to verify correct data was saved to database
                using (var context = new EfstoreContext(options))
                {
                    Assert.AreEqual(1, context.shopbaskets.Count());
                    // Assert.AreEqual("Adiddas", context.shopbaskets.Single().Name);
                    Assert.AreEqual("4", context.shopbaskets.Single().OrderLines);
                }

                {
                }
            }
        }
示例#3
0
        public void ServiceLayer_Prod_INF_Test()
        {
            var options = new DbContextOptionsBuilder <EfstoreContext>()
                          .UseInMemoryDatabase(databaseName: "WebstoreDB").Options;

            using (var op = new EfstoreContext(options))
            {
                Productinfo PI = new Productinfo();
                // PI.productinfoID = 1;
                PI.Brand = "Adiddas";
                PI.Color = "Black";
                PI.size  = "L";
                var PS = new ProductInfoService(op);
                PS.Add(PI);
                // Use a separate instance of the context to verify correct data was saved to database
                using (var context = new EfstoreContext(options))
                {
                    Assert.AreEqual(1, context.Prodinfo.Count());
                    Assert.AreEqual(1, context.Prodinfo.Single().productinfoID);
                    Assert.AreEqual("Black", context.Prodinfo.Single().Color);
                }

                {
                }
            }
        }
示例#4
0
        public void ServiceLayer_Prod_Test()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <EfstoreContext>()
                          .UseInMemoryDatabase(databaseName: "WebstoreDB").Options;

            //ACT
            using (var op = new EfstoreContext(options))
            {
                Products p = new Products();
                p.ClothingID  = 1;
                p.name        = "Adiddas A1 Running";
                p.Description = "Running Shoe with special Gel";
                p.price       = 300;
                p.status      = "Instock";
                var op1 = new ProductService(op);
                op1.Add(p);

                //Assert
                // Use a separate instance of the context to verify correct data was saved to database
                using (var context = new EfstoreContext(options))
                {
                    //  Assert.AreEqual(1, context.Products.Count());
                    Assert.AreEqual(1, context.Products.Single().ClothingID);
                    Assert.AreNotEqual(0, context.Products.Single().ClothingID);
                }

                {
                }
            }
        }
示例#5
0
        private List <Products> GetProducts()
        {
            var context = new EfstoreContext();

            PS = new ProductService(context);
            List <Products> pd = PS.GetProducts();

            return(pd);
        }
示例#6
0
        private IQueryable <Products> GetProduct(int i)
        {
            var context = new EfstoreContext();

            PS = new ProductService(context);
            IQueryable <Products> pd = PS.GetProductById(i);

            return(pd);
        }
示例#7
0
        private List <Shopbasket> GetProdBasket(int i)
        {
            var context = new EfstoreContext();

            SS = new ShopbasketService(context);
            List <Shopbasket> pd = SS.GetShopBasketById(i);

            return(pd);
        }
示例#8
0
        public void OnPostDelete(int ClothingID)
        {
            var context = new EfstoreContext();

            SS = new ShopbasketService(context);


            SS.Delete(4);
        }
示例#9
0
        private userinformation GetUserInfOne(int i)
        {
            var context = new EfstoreContext();

            US = new UserinformationService(context);
            userinformation pd = US.GetuserinfById(i);

            return(pd);
        }
示例#10
0
        public List <Products> GetProductsByprice(int price)
        {
            var context       = new EfstoreContext();
            var SelectProduct = context.Products
                                .Where(s => s.price == price)
                                .ToList();
            List <Products> pd = SelectProduct.ToList <Products>();

            return(pd);
        }
示例#11
0
        public List <Products> GetProducts()
        {
            var context       = new EfstoreContext();
            var SelectProduct = context.Products
                                .Select(x => x)
                                .ToList();
            List <Products> pd = SelectProduct.ToList <Products>();

            return(pd);
        }
示例#12
0
        public List <Shopbasket> GetShopBasketById(int Id)
        {
            var context          = new EfstoreContext();
            var SelectShopBasket = context.shopbaskets
                                   .Where(s => s.ClothingID == Id)
                                   .ToList();
            List <Shopbasket> pd = SelectShopBasket.ToList <Shopbasket>();

            return(pd);
        }
示例#13
0
        public List <Products> GetProductById1(int Id)
        {
            var context       = new EfstoreContext();
            var SelectProduct = context.Products
                                .Where(s => s.ClothingID == Id)
                                .ToList();
            List <Products> pd = SelectProduct.ToList <Products>();

            return(pd);
        }
示例#14
0
        public List <Products> GetProductsByDSC()
        {
            var context       = new EfstoreContext();
            var SelectProduct = context.Products
                                .OrderByDescending(x => x.price)
                                .ToList();
            List <Products> pd = SelectProduct.ToList <Products>();

            return(pd);
        }
示例#15
0
        public List <Products> GetProductsByname(string name)
        {
            var context       = new EfstoreContext();
            var SelectProduct = context.Products
                                .Where(s => s.name == name)
                                .ToList();
            List <Products> pd = SelectProduct.ToList <Products>();

            return(pd);
        }
示例#16
0
        public List <userinformation> GetUserinformation()
        {
            var context       = new EfstoreContext();
            var SelectProduct = context.userinformtation
                                .Select(x => x)
                                .ToList();
            List <userinformation> pd = SelectProduct.ToList <userinformation>();

            return(pd);
        }
示例#17
0
        public void OnPost(string fullname, string Address, String Email, string paymentO)
        {
            var context = new EfstoreContext();

            OS = new OrderService(context);
            Orders ord = new Orders();

            // ord.OrderId = 34;


            //SS.Add(sb);
        }
示例#18
0
        private List <userinformation> Getuserinf()
        {
            //  _db.user.ToList();


            var context = new EfstoreContext();

            US = new UserinformationService(context);
            List <userinformation> pd = US.GetUserinformation();

            return(pd);
        }
示例#19
0
        public List <Shopbasket> GetShopBasket()
        {
            var context       = new EfstoreContext();
            var SelectProduct = context.shopbaskets
                                .Select(x => x)
                                .ToList();
            List <Shopbasket> pd = SelectProduct.ToList <Shopbasket>();

            return(pd);



            //   return _ctx.shopbaskets;
        }
示例#20
0
        public List <Products> GetProducts()
        {
            var cacheEntry = DateTime.Now;

            _cache.Set <DateTime>("Time", cacheEntry);
            var context = new EfstoreContext();

            PS = new ProductService(context);
            List <Products> pd      = PS.GetProducts();
            var             myEntry = _cache.Get("myKey");

            //  var myEntry = _cache.Get<DateTime>("myKey");
            return(pd);
        }
示例#21
0
        public TodoController(EfstoreContext context)
        {
            _context = context;

            if (_context.TodoItems.Count() == 0)
            {
                // Create a new TodoItem if collection is empty,
                // which means you can't delete all TodoItems.
                _context.TodoItems.Add(new TodoItem {
                    Name = "Item1"
                });
                _context.SaveChanges();
            }
        }
示例#22
0
        private List <Products> GetProduct(int i)
        {
            var context = new EfstoreContext();

            PS = new ProductService(context);
            List <Products> pd = PS.GetProducts();

            var SelectProduct = context.Products
                                .Where(s => s.ClothingID == i)
                                .ToList();
            List <Products> ps = SelectProduct.ToList <Products>();

            return(ps);
        }
示例#23
0
        public void OnPostView(int id)
        {
            var            context   = new EfstoreContext();
            ProductService PS        = new ProductService(context);
            Products       smallProd = new Products();



            smallProd.ClothingID  = 35;
            smallProd.Description = desc;
            smallProd.price       = pric;
            smallProd.status      = "Instock";
            smallProd.name        = name;
            PS.Add(smallProd);
        }
示例#24
0
        public ProductController(EfstoreContext context)
        {
            _context = context;

            if (_context.prod.Count() == 0)
            {
                // Create a new TodoItem if collection is empty,
                // which means you can't delete all TodoItems.
                _context.prod.Add(new Products {
                    name = "Adidas A1", Description = "Test", price = 100, status = "Instock"
                });

                _context.SaveChanges();
            }
        }
示例#25
0
        public void OnPostSearchDSC()
        {
            prod = _db.prod.ToList();

            var context = new EfstoreContext();

            PS = new ProductService(context);

            List <Products> PS1 = PS.GetProducts();


            final = PS1.OrderByDescending(s => s.price).ToList <Products>();


            prod2 = final;
        }
示例#26
0
        public void OnPostSearchBrand(string SearchString)
        {
            prod = _db.prod.ToList();


            if (!String.IsNullOrEmpty(SearchString))
            {
                var context = new EfstoreContext();
                PS = new ProductService(context);

                List <Products> PS1 = PS.GetProducts();

                final = PS1.Where(s => s.Brand.Contains(SearchString)).ToList <Products>();
                prod2 = final;
            }
        }
示例#27
0
        public void OnPostSearchASC()
        {
            prod = _db.prod.ToList();

            var context = new EfstoreContext();

            PS = new ProductService(context);

            List <Products> PS1 = PS.GetProducts();


            var orderByResult = from s in PS1
                                orderby s.price
                                select s;

            final = orderByResult.ToList <Products>();


            prod2 = final;
        }
示例#28
0
        public void OnPostBasket(int id)
        {
            prod = _db.prod.ToList();


            var context = new EfstoreContext();

            SS = new ShopbasketService(context);

            Shopbasket sb = new Shopbasket();

            foreach (Products p in prod)
            {
                sb.ClothingID = p.ClothingID;
                sb.Name       = p.name;
                sb.Quantity   = 1;
                sb.OrderLines = "1";
                sb.Product_id = 1;
            }
            SS.Add(sb);
        }
示例#29
0
        //    return View(await students.AsNoTracking().ToListAsync());
        //}
        //ViewData["CurrentFilter"] = searchString;

        //    if (!String.IsNullOrEmpty(searchString))
        //    {
        //        students = students.Where(s => s.LastName.Contains(searchString)
        //                               || s.FirstMidName.Contains(searchString));
        //    }



        //    using (MiniProfiler.Current.Step("InitUser"))
        //    {
        //        string one = "";
        //        SorbyBrand = one;


        //        List<Products> pr = GetProducts();
        //        int products = GetProducts().Count;

        //        foreach (Products p in pr)
        //        {



        //             id = p.ClothingID;
        //             name = p.name;
        //             desc = p.Description;
        //             pric = p.price;
        //             stat = p.status;

        //            ViewData["ClothingID "] = id;
        //            ViewData["name "] = name;
        //            ViewData["Description "] = desc;
        //            ViewData["Price "] = pric;
        //            ViewData["status"] = stat;


        //        }

        //    }
        //}

        public List <Products> GetProductsSearch(string searchString)
        {
            var context = new EfstoreContext();

            PS = new ProductService(context);
            List <Products> pd = PS.GetProducts();
            List <Products> pd2;
            var             Products = from s in context.prod
                                       select s;

            if (!String.IsNullOrEmpty(searchString))
            {
                Products = Products.Where(s => s.Description.Contains(searchString));
            }

            ViewData["CurrentFilter"] = searchString;
            //prod = _db.prod.ToList();

            //IEnumerable<Products> prod2 = prod.OrderByDescending(s => s.price);

            return(Products.ToList <Products>());
        }
示例#30
0
        public userinformation one()
        {
            EfstoreContext efx = new EfstoreContext();
            // UserinformationService ser1 = new UserinformationService(efx);


            userinformation sb = new userinformation();
            ////sb.id = 1;
            //sb.fullname = "Hansen";
            //sb.Address = "Hansenvej 1";
            //sb.dateofbirth = DateTime.Now;
            //sb.CountryCode = 1100;
            //sb.city = "hansenberg";
            //sb.gender = "M";
            //sb.paymentO = "MasterCard";
            //ser1.Add(sb);

            ShopbasketService sb1 = new ShopbasketService(efx);

            sb1.Delete(0);

            return(sb);



            //Shopbasket sb = new Shopbasket();


            //IQueryable<Products> ps =       prod1.GetProductById(2);



            //var context = new EfstoreContext();
            //var studentsWithSameName = context.Products
            //                                  .Where(s => s.ClothingID == 2)
            //                                  .ToList();

            //List<Products> pd = studentsWithSameName.ToList<Products>();
        }