1234567891011121314151617181920212223242526272829303132333435 |
- 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.Run();
|