12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- using api_asp.net.models;
- using Dapper;
- using MySqlConnector;
- var builder = WebApplication.CreateBuilder(args);
- var app = builder.Build();
- var dbDataProvider = new DBDataProvider();
- app.MapGet("/product", (int? pageNum) =>
- {
- return dbDataProvider.getProduct(pageNum ?? 1);
- });
- app.MapPost("/product", (Product newProduct) =>
- {
- dbDataProvider.saveProduct(newProduct);
- });
- app.MapDelete(
- "/product/{id:int}",
- (int id) =>
- {
- dbDataProvider.removeProduct(id);
- });
- app.MapPut("/product", (Product editProduct) =>
- {
- dbDataProvider.saveProduct(editProduct);
- });
- app.MapGet("/productCount", () =>
- {
- return dbDataProvider.getProductCount();
- });
- app.MapPut("/minCostForAgent/{minCost:decimal}", (decimal minCost, int[] ids) =>
- {
- dbDataProvider.setMinCostForAgent(minCost, ids);
- });
- app.MapGet("/saleCount/{ID:int}", (int ID) =>
- {
- return dbDataProvider.saleCount(ID);
- });
- app.MapDelete("/productMaterial/{ID:int}", (int ID) =>
- {
- dbDataProvider.removeProductMaterial(ID);
- });
- app.MapDelete("/PriceHistory/{ID:int}", (int ID) =>
- {
- dbDataProvider.removePriceHistory(ID);
- });
- app.MapGet("/productMaterial/{ID:int}", (int ID) =>
- {
- return dbDataProvider.getProductMaterials(ID);
- });
- app.MapGet("/AvailableMaterials", () =>
- {
- return dbDataProvider.getAvailableMaterials();
- });
- app.MapGet("/ProductTypes", () =>
- {
- return dbDataProvider.getProductTypes();
- });
- app.MapPost("/productMaterial", (ProductMaterial material) =>
- {
- dbDataProvider.addProductMaterial(material);
- });
- app.MapPut("/setOrder", (string condition) =>
- {
- dbDataProvider.setOrder(condition);
- });
- app.MapPut("/addFilter", (string name, object value) =>
- {
- dbDataProvider.addFilter(name, value);
- });
- app.MapPut("/clearFilter", () =>
- {
- dbDataProvider.clearFilter();
- });
- app.Run();
|