//Read public static CoffeeShopLabTable Read(long _id) { IDbConnection db = new SqlConnection("Server=HN78Q13\\SQLEXPRESS;Database=CoffeeShopLab;user id=testuser;password=abc123"); CoffeeShopLabTable prod = db.Get <CoffeeShopLabTable>(_id); return(prod); }
public static CoffeeShopLabTable AddProduct(string _name, decimal _price, string _description, string _category) { // Create the new Product instance CoffeeShopLabTable prod = new CoffeeShopLabTable() { Name = _name, Price = _price, Description = _description, Category = _category }; //Save it to the database IDbConnection db = new SqlConnection("Server=HN78Q13\\SQLEXPRESS;Database=CoffeeShopLab;user id=testuser;password=abc123"); long _id = db.Insert <CoffeeShopLabTable>(prod); //Set the id column of the instance prod.id = _id; //Return the instance return(prod); }