public void UpdateWarehouseDb() { var warehouseDb = new DbWarehouse(); var prod = new Product { Id = 1, Category = "category", Description = "ddeskr", Name = "banan", Price = 10 }; var shop = new Shop { Name = "ShopName", Address = "new addr", OpeningTime = "Manday Never", Chain = new DbChain().GetChain(1), Cvr = "12121212", Warehouses = new List <Warehouse>() }; var shopId = new DbShop().AddShop(shop); shop.Id = shopId; var warehouseToUpdate = new Warehouse(1, 1, prod, shop, null); var id = warehouseDb.AddWarehouse(warehouseToUpdate); warehouseToUpdate.Id = id; var warehouseNew = new Warehouse(id, 100, 50, prod, shop, 1); warehouseDb.UpdateWarehouse(warehouseNew); var updatedWarehouse = warehouseDb.GetWarehouse(id); Assert.AreEqual(warehouseNew.Stock, updatedWarehouse.Stock); }
public void GetShopDb() { var dbShop = new DbShop(); var shop = new Shop() { Name = "hello world", Address = "Hello address", OpeningTime = "Manday Never", Cvr = "12121212", Warehouses = new List <Warehouse>(), Chain = new Chain { Id = 1, Cvr = "12121212", Name = "", Persons = new List <Person>(), Shops = new List <Shop>() } }; var i = dbShop.AddShop(shop); var j = dbShop.GetShop(i); dbShop.DeleteShop(i); Assert.IsNotNull(j); }
public ActionResult DoUpload(IFormFile file) { using (var stream = file.OpenReadStream()) { var xs = new XmlSerializer(typeof(GunShop.Shop)); var shop = (GunShop.Shop)xs.Deserialize(stream); using (var db = new ShopDbContext()) { var dbs = new DbShop() { Name = shop.Name, Address = shop.Address, Photo = shop.Photo, Contacts = shop.Contacts, }; dbs.Guns = new Collection <DbSpecifications>(); foreach (var specifications in shop.Guns) { dbs.Guns.Add(new DbSpecifications() { Name = specifications.Name, ProductionDate = specifications.ProductionDate, GunType = specifications.GunType, Caliber = specifications.Caliber, Price = specifications.Price, Weight = specifications.Weight, }); } db.Shops.Add(dbs); db.SaveChanges(); } return(View(shop)); } }
public void GetWarehouseDb() { var warehouseDb = new DbWarehouse(); var prod = new Product { Id = 1, Category = "category", Description = "ddeskr", Name = "banan", Price = 10 }; var shop = new Shop { Name = "ShopName", Address = "new addr", OpeningTime = "Manday Never", Chain = new DbChain().GetChain(1), Cvr = "12121212", Warehouses = new List <Warehouse>() }; var shopId = new DbShop().AddShop(shop); shop.Id = shopId; var warehouse = new Warehouse(10, 5, prod, shop, 1); var id = warehouseDb.AddWarehouse(warehouse); var rw = warehouseDb.GetWarehouse(id); Assert.IsNotNull(rw); }
public UnitTest1() { options = new DbContextOptionsBuilder <DbShop>() .UseInMemoryDatabase(databaseName: "InMemoryDatabase") .Options; context = new DbShop(options); }
public void TestConcurrencyLessThenMaxAmount() { var i1 = 0; var i2 = 0; var prod = new Product("TestProd1", new decimal(10), "TestDescription", "Oste", "TestPath"); var s = new Shop("TestShop1", "TestAddress", "12345678", "OpeningTime", new DbChain().GetChain(1), new List <Warehouse>()); //add product to database int prodId = new DbProduct().AddProduct(prod); prod.Id = prodId; //add shop to database var shopId = new DbShop().AddShop(s); s.Id = shopId; //add warehouse to databse and add it to shop var warehouse = new Warehouse(10, 0, prod, s, null); var warId = new DbWarehouse().AddWarehouse(warehouse); warehouse.Id = warId; s.Warehouses.Add(warehouse); //make cart1 with part order var cart1 = new Cart(); var po1 = new PartOrder(prod, 5, 20); cart1.PartOrders.Add(po1); cart1.PersonId = _cust.Id; cart1.ShopId = s.Id; //make cart2 with part order var cart2 = new Cart(); var po2 = new PartOrder(prod, 2, 20); cart2.PartOrders.Add(po2); cart2.PersonId = _cust1.Id; cart2.ShopId = s.Id; //start 2 parallel queries var cartDb = new DbCart(); Parallel.Invoke(() => { i1 = cartDb.AddCartWithPartOrders(cart1); }, () => { i2 = cartDb.AddCartWithPartOrders(cart2); }); //var antal = new DbWarehouse().GetWarehouse(warId).Stock; var flag = 0; if (i1 == 0 || i2 == 0) { flag = 1; } Assert.AreEqual(1, flag); }
public WebShopController(DbShop context) { _context = context; }
public ReviewContentController(DbShop context) { _context = context; }
public MeasuringUnitController(DbShop context) { _context = context; }
public RepositoryUnit(DbShop context) { _context = context; }
public ProductCategoryController(DbShop context) { _context = context; }
public CheckOutController(DbShop contex) { _context = contex; carts = new List <Cart>(); }
public HomeController(DbShop context) { _context = context; }
public CategoryController(DbShop context) { _context = context; }
public ModelPaging(DbShop context) { _context = context; Data = _context.ProductCategory.Include(x => x.Product).Include(x => x.Category).ToList(); Count = Data.Count; }
public CartController(DbShop dbShop) { _context = dbShop; carts = new List <Cart>(); }