P1_TrevorGraham/MvcStoreApplication/Repository/Repository.cs
/// <summary>
/// attempts to add a product to the db, returns whether or not it was successful
/// </summary>
/// <param name="product"></param>
/// <returns></returns>
attempts to add a product to the db, returns whether or not it was successful
attempts to add a product to the db returns whether or not it was successful
public bool AttemptAddProductToDb(Product product)
        {
            if(!ProductIsInDb(product))
            {
                _dbContext.Products.Add(product);
                _dbContext.SaveChanges();
                return ProductIsInDb(product);
            }
            return false;
        }
public bool AttemptAddProductToDb ( Product product ) { if ( ! ProductIsInDb ( product ) ) { _dbContext . Products . Add ( product ) ; _dbContext . SaveChanges ( ) ; return ProductIsInDb ( product ) ; } return false ; }
attempts to add a product to the db, returns whether or not it was successful
attempts to add a product to the db returns whether or not it was successful
//if there is not a product in the db with the same id or name //add it
None
product
Product
None