P0_TrevorGraham/StoreApplication/StoreMain/Logic/StoreSession.cs
/// <summary>
/// Adds product to db; returns false if product name already exists in db
/// </summary>
/// <param name="name">Product Name</param>
/// <param name="price">Product Price</param>
/// <param name="description">Product Description</param>
/// <returns></returns>
Adds product to db; returns false if product name already exists in db
Adds product to db ; returns false if product name already exists in db
public bool AddProductToDb(string name, double price, string description){
            if(db.Products.SingleOrDefault(x => x.ProductName ==name)!=null){
                return false;
            }
            Product newProduct = new Product(){
                ProductName = name,
                Price = price,
                Description = description,
            };
            db.Products.Add(newProduct);
            db.SaveChanges();
            return true;
        }
public bool AddProductToDb ( string name , double price , string description ) { if ( db . Products . SingleOrDefault ( x => x . ProductName == name ) != null ) { return false ; } Product newProduct = new Product ( ) { ProductName = name , Price = price , Description = description , } ; db . Products . Add ( newProduct ) ; db . SaveChanges ( ) ; return true ; }
Adds product to db; returns false if product name already exists in db
Adds product to db ; returns false if product name already exists in db
//TODO: any checks to perform? //product already exists in db
None
name
string
None
price
double
None
description
string
None