Web client & employee

This commit is contained in:
Илья Федотов 2024-05-27 18:36:13 +04:00
parent d8beafb61f
commit 55e743f915
3 changed files with 26 additions and 4 deletions

View File

@ -91,12 +91,29 @@ namespace ElectronicsShopEmployeeApp.Controllers {
[HttpGet] [HttpGet]
public IActionResult Create() { public IActionResult Create() {
ViewBag.Orders = APIEmployee.GetRequset<List<OrderViewModel>>("api/main/getproductlist"); ViewBag.Orders = APIEmployee.GetRequset<List<ProductViewModel>>("api/main/getproductlist");
return View(); return View();
} }
public void Create(OrderBindingModel order) { [HttpPost]
throw new NotImplementedException(); public void Create(int price, int costItem, string productName) {
if (APIEmployee.Employee == null) {
throw new Exception("Ňîëüęî äë˙ ŕâňîđčçîâŕííűő");
}
if (price <= 0) {
throw new Exception("Ńňîčěîńňü ňîâŕđŕ äîëćíŕ áűňü áîëüřĺ 0");
}
APIEmployee.PostRequest("api/main/createproduct", new ProductBindingModel {
CostItemID = costItem,
ProductName = productName,
Price = Calc(price, costItem)
});
Response.Redirect("Index");
}
private double Calc(int price, int costItem) {
var _costItem = APIEmployee.GetRequset<CostItemViewModel>($"api/main/getcostitem?_employeeID={costItem}");
return price * (_costItem?.Price ?? 1);
} }
} }
} }

View File

@ -31,6 +31,9 @@
<li class="nav-item"> <li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a>
</li> </li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="CreateCostItem">Создание статьи затрат</a>
</li>
</ul> </ul>
</div> </div>
</div> </div>

View File

@ -13,10 +13,12 @@ var builder = WebApplication.CreateBuilder(args);
builder.Services.AddTransient<IClientStorage, ClientStorage>(); builder.Services.AddTransient<IClientStorage, ClientStorage>();
builder.Services.AddTransient<IEmployeeStorage, EmployeeStorage>(); builder.Services.AddTransient<IEmployeeStorage, EmployeeStorage>();
builder.Services.AddTransient<IProductStorage, ProductStorage>(); builder.Services.AddTransient<IProductStorage, ProductStorage>();
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
builder.Services.AddTransient<IClientLogic, ClientLogic>(); builder.Services.AddTransient<IClientLogic, ClientLogic>();
builder.Services.AddTransient<IEmployeeLogic, EmployeeLogic>(); builder.Services.AddTransient<IEmployeeLogic, EmployeeLogic>();
builder.Services.AddTransient<IProductLogic, ProductLogic>(); builder.Services.AddTransient<IProductLogic, ProductLogic>();
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
builder.Services.AddControllers(); builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle