internal void AddLocationsWithInventory() { AddSomeProducts(); AddLocations(); using (var ctx = new VendorContext()) { ProductInventorieService pIServ = new ProductInventorieService(ctx); LocationService lServ = new LocationService(ctx); ProductService pServ = new ProductService(ctx); var prod1 = pServ.FindByName("Stimpak"); var prod2 = pServ.FindByName("Buffout"); var prod3 = pServ.FindByName("10mm"); var loc1 = lServ.FindByName("The Mojave Wasteland"); lServ.AddProductToInventory(loc1.LocationId, prod1.ProductId, 1); lServ.AddProductToInventory(loc1.LocationId, prod2.ProductId, 4); var loc2 = lServ.FindByName("The Capital Warehouse Store"); lServ.AddProductToInventory(loc2.LocationId, prod3.ProductId, 1); lServ.AddProductToInventory(loc2.LocationId, prod2.ProductId, 4); } }
/// <summary> /// Retrieves the inventory of a Product from a certain Location /// </summary> /// <param name="location">The Location used to find the inventory</param> /// <param name="product">The Product used to find the inventory</param> /// <returns></returns> public ProductInventory GetProductInventory(Location location, Product product) { ProductInventory productInventory; using (var ctx = new VendorContext()) { ProductInventorieService pIS = new ProductInventorieService(ctx); productInventory = pIS.GetInventory(location, product); } return(productInventory); }
/// <summary> /// Fetches the inventory of the specified location /// </summary> /// <param name="locationName">Location's name used to retrive inventory</param> /// <returns>List of a location's inventory</returns> public List <ProductInventory> RetrieveInventoryByLocationName(string locationName) { List <ProductInventory> locationInventory; using (var ctx = new VendorContext()) { ProductInventorieService pIS = new ProductInventorieService(ctx); locationInventory = pIS.FindProductInventoryByLocationName(locationName); } return(locationInventory); }
/// <summary> /// Update's the inventory record of the amount of a Location's specific product /// </summary> /// <param name="location">The Location who's inentory will be updated</param> /// <param name="product">The product that will be added/removed from the location</param> /// <param name="quantity">The new quantity of the prouct that the current location will carry.</param> /// <returns></returns> public ProductInventory UpdateInventory(Location location, Product product, int quantity) { ProductInventory productInventory; using (var ctx = new VendorContext()) { ProductInventorieService pIS = new ProductInventorieService(ctx); productInventory = pIS.UpdateInventory(location, product, quantity); } return(productInventory); }
/// <summary> /// Fetches the inventory of the specified location /// </summary> /// <param name="locationName">Location's name used to retrive inventory</param> /// <returns>A Packet that contains a list of the inventory the location has</returns> public Packet <ProductInventory> RetrieveInventoryPacketByLocationName(string locationName) { List <ProductInventory> locationInventory; string locationInventoryStrList; using (var ctx = new VendorContext()) { ProductInventorieService pIS = new ProductInventorieService(ctx); locationInventory = pIS.FindProductInventoryByLocationName(locationName); } locationInventoryStrList = $"Inventory for {locationName}:\n"; foreach (var inventory in locationInventory) { locationInventoryStrList += $"Product:\n{inventory.Product.Name} - Quantity:\n{inventory.Quanitity}\n\n"; } return(new Packet <ProductInventory> { Text = locationInventoryStrList, Status = PacketStatus.Pass }); }