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); } { } } }
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); } { } } }
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); } { } } }
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); } { } } }
private List <Products> GetProducts() { var context = new EfstoreContext(); PS = new ProductService(context); List <Products> pd = PS.GetProducts(); return(pd); }
private IQueryable <Products> GetProduct(int i) { var context = new EfstoreContext(); PS = new ProductService(context); IQueryable <Products> pd = PS.GetProductById(i); return(pd); }
private List <Shopbasket> GetProdBasket(int i) { var context = new EfstoreContext(); SS = new ShopbasketService(context); List <Shopbasket> pd = SS.GetShopBasketById(i); return(pd); }
public void OnPostDelete(int ClothingID) { var context = new EfstoreContext(); SS = new ShopbasketService(context); SS.Delete(4); }
private userinformation GetUserInfOne(int i) { var context = new EfstoreContext(); US = new UserinformationService(context); userinformation pd = US.GetuserinfById(i); return(pd); }
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); }
public List <Products> GetProducts() { var context = new EfstoreContext(); var SelectProduct = context.Products .Select(x => x) .ToList(); List <Products> pd = SelectProduct.ToList <Products>(); return(pd); }
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); }
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); }
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); }
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); }
public List <userinformation> GetUserinformation() { var context = new EfstoreContext(); var SelectProduct = context.userinformtation .Select(x => x) .ToList(); List <userinformation> pd = SelectProduct.ToList <userinformation>(); return(pd); }
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); }
private List <userinformation> Getuserinf() { // _db.user.ToList(); var context = new EfstoreContext(); US = new UserinformationService(context); List <userinformation> pd = US.GetUserinformation(); return(pd); }
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; }
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); }
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(); } }
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); }
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); }
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(); } }
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; }
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; } }
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; }
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); }
// 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>()); }
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>(); }