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();