123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- using WebApplication1.models;
- 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.MapPut("/product",
- (Product editProduct) =>
- {
- dbDataProvider.saveProduct(editProduct);
- });
- 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();
|