P1_TrevorGraham/MvcStoreApplication/Repository/Repository.cs
/// <summary>
/// Attempts to add a product to an inventory, returns whether or not it was successful
/// </summary>
/// <param name="product"></param>
/// <param name="location"></param>
/// <param name="quantity"></param>
/// <returns></returns>
Attempts to add a product to an inventory, returns whether or not it was successful
Attempts to add a product to an inventory returns whether or not it was successful
public bool AttemptAddProductToStore(Product product, Location location, int quantity)
        {
            if (ProductIsInDb(product) && LocationIsInDb(location))
            {
                Inventory inventory = new Inventory()
                {
                    Location = location,
                    Product = product,
                    Quantity = quantity
                };
                _dbContext.Inventories.Add(inventory);
                _dbContext.SaveChanges();
                return (InventoryIsInDb(inventory));
            }
            return false;
        }
public bool AttemptAddProductToStore ( Product product , Location location , int quantity ) { if ( ProductIsInDb ( product ) && LocationIsInDb ( location ) ) { Inventory inventory = new Inventory ( ) { Location = location , Product = product , Quantity = quantity } ; _dbContext . Inventories . Add ( inventory ) ; _dbContext . SaveChanges ( ) ; return ( InventoryIsInDb ( inventory ) ) ; } return false ; }
Attempts to add a product to an inventory, returns whether or not it was successful
Attempts to add a product to an inventory returns whether or not it was successful
None
product
Product
None
location
Location
None
quantity
int
None