>("api/main/getproductlist");
@@ -96,7 +117,7 @@ namespace ElectronicsShopEmployeeApp.Controllers {
}
[HttpPost]
- public void Create(int price, int costItem, string productName) {
+ public void Create(int price, int costNum, string productName) {
if (APIEmployee.Employee == null) {
throw new Exception(" ");
}
@@ -104,9 +125,9 @@ namespace ElectronicsShopEmployeeApp.Controllers {
throw new Exception(" 0");
}
APIEmployee.PostRequest("api/main/createproduct", new ProductBindingModel {
- CostItemID = costItem,
+ CostItemID = costNum,
ProductName = productName,
- Price = Calc(price, costItem)
+ Price = Calc(price, costNum)
});
Response.Redirect("Index");
}
diff --git a/ElectronicsShop/ElectronicsShopEmployeeApp/Views/Home/CreateCostItem.cshtml b/ElectronicsShop/ElectronicsShopEmployeeApp/Views/Home/CreateCostItem.cshtml
new file mode 100644
index 0000000..d9d921c
--- /dev/null
+++ b/ElectronicsShop/ElectronicsShopEmployeeApp/Views/Home/CreateCostItem.cshtml
@@ -0,0 +1,47 @@
+@{
+ ViewData["Title"] = "CreateCostItem";
+}
+
+
+
Создание статьи затрат
+
+
+
+
\ No newline at end of file
diff --git a/ElectronicsShop/ElectronicsShopRestAPI/Controllers/MainController.cs b/ElectronicsShop/ElectronicsShopRestAPI/Controllers/MainController.cs
index 7fa5473..0548887 100644
--- a/ElectronicsShop/ElectronicsShopRestAPI/Controllers/MainController.cs
+++ b/ElectronicsShop/ElectronicsShopRestAPI/Controllers/MainController.cs
@@ -14,11 +14,14 @@ namespace ElectronicsShopRestAPI.Controllers {
private readonly ILogger _logger;
private readonly IProductLogic _product;
private readonly IOrderLogic _order;
+ private readonly ICostItemLogic _costItem;
- public MainController(ILogger logger, IProductLogic product, IOrderLogic orderLogic) {
+ public MainController(ILogger logger, IProductLogic product,
+ IOrderLogic orderLogic, ICostItemLogic costItemLogic) {
_logger = logger;
_product = product;
_order = orderLogic;
+ _costItem = costItemLogic;
}
[HttpGet]
@@ -72,6 +75,17 @@ namespace ElectronicsShopRestAPI.Controllers {
return;
}
- //Мейби нужны будут удаления, обновления, выбор конкретного заказа или продукта. Короче потом....
+ [HttpPost]
+ public void CreateCostItem(CostItemBindingModel model) {
+ try {
+ _costItem.Create(model);
+ }
+ catch (Exception ex) {
+ _logger.LogError(ex, "Ошибка создания заказа");
+ throw;
+ }
+ }
+ //Мейби нужны будут удаления, обновления, выбор конкретного заказа или продукта. Короче потом...
+ //А также для статей затрат.
}
}
diff --git a/ElectronicsShop/ElectronicsShopRestAPI/Program.cs b/ElectronicsShop/ElectronicsShopRestAPI/Program.cs
index 831a84b..1b0f4c2 100644
--- a/ElectronicsShop/ElectronicsShopRestAPI/Program.cs
+++ b/ElectronicsShop/ElectronicsShopRestAPI/Program.cs
@@ -14,11 +14,13 @@ builder.Services.AddTransient();
builder.Services.AddTransient();
builder.Services.AddTransient();
builder.Services.AddTransient();
+builder.Services.AddTransient();
builder.Services.AddTransient();
builder.Services.AddTransient();
builder.Services.AddTransient();
builder.Services.AddTransient();
+builder.Services.AddTransient();
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle