public static int InsertProduct(Product p , IEnumerable<Claim> claims) { string sql = "INSERT INTO Product VALUES(@ProductName,@Price)"; DbParameter par1 = Database.AddParameter(Database.ADMIN_DB, "@ProductName", p.ProductName); DbParameter par2 = Database.AddParameter(Database.ADMIN_DB, "@Price", p.Price); return Database.InsertData(Database.GetConnection(CreateConnectionString(claims)), sql, par1, par2); }
public HttpResponseMessage Put(Product pr) { ClaimsPrincipal p = RequestContext.Principal as ClaimsPrincipal; ProductsDA.UpdateProduct(pr, p.Claims); return new HttpResponseMessage(HttpStatusCode.OK); }
public static int UpdateProduct(Product p, IEnumerable<Claim> claims) { string sql = "UPDATE Product SET ProductName=@ProductName, Price=@Price WHERE ID=@ID"; DbParameter par1 = Database.AddParameter(Database.ADMIN_DB, "@ProductName", p.ProductName); DbParameter par2 = Database.AddParameter(Database.ADMIN_DB, "@Price", p.Price); DbParameter par3 = Database.AddParameter(Database.ADMIN_DB, "@ID", p.ID); return Database.ModifyData(Database.GetConnection(CreateConnectionString(claims)), sql, par1, par2, par3); }
public HttpResponseMessage Post(Product pr) { ClaimsPrincipal p = RequestContext.Principal as ClaimsPrincipal; int id = ProductsDA.InsertProduct(pr, p.Claims); HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.OK); message.Content = new StringContent(id.ToString()); return message; }
public static List<Sale> GetSalesByProductID(Product p, IEnumerable<Claim> claims) { List<Sale> list = new List<Sale>(); string sql = "SELECT * FROM Sale WHERE ProductID=@ID"; DbParameter parID = Database.AddParameter(Database.ADMIN_DB, "@ID", p.ID); DbDataReader reader = Database.GetData(Database.GetConnection(CreateConnectionString(claims)), sql, parID); while (reader.Read()) { list.Add(Create(reader)); } reader.Close(); return list; }
public static List<Sale> GetSalesByCustRegProdID(Customer c, Register r, Product p, IEnumerable<Claim> claims) { List<Sale> list = new List<Sale>(); string sql = "SELECT * FROM Sale WHERE CustomerID=@CID And RegisterID=@RID And ProductID=@PID"; DbParameter parCID = Database.AddParameter(Database.ADMIN_DB, "@CID", c.ID); DbParameter parRID = Database.AddParameter(Database.ADMIN_DB, "@RID", r.ID); DbParameter parPID = Database.AddParameter(Database.ADMIN_DB, "@PID", p.ID); DbDataReader reader = Database.GetData(Database.GetConnection(CreateConnectionString(claims)), sql, parCID, parRID, parPID); while (reader.Read()) { list.Add(Create(reader)); } reader.Close(); return list; }
private void NewProduct() { Product p = new Product(); Products.Add(p); SelectedProduct = p; }