я всё забыл
This commit is contained in:
parent
2bba322faa
commit
c33bbce640
@ -12,7 +12,7 @@ namespace ElectronicsShopDataBaseImplement
|
||||
optionsBuilder)
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false) {
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-O0N00SH\SQLEXPRESS;Initial Catalog=ElectronicsShopDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-E2VPEN3\SQLEXPRESS;Initial Catalog=ElectronicsShopDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
@ -103,20 +103,11 @@ namespace ElectronicsShopRestAPI.Controllers {
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_order.ReadElement(new OrderSearchModel { ID = model.ID })==null)
|
||||
{
|
||||
CreateOrder( new OrderBindingModel
|
||||
{
|
||||
ClientID = model.ClientID,
|
||||
ProductList = model.ProductList,//Суда поступает пустой список
|
||||
Sum = model.Sum
|
||||
});
|
||||
}
|
||||
var order=_order.ReadElement(new OrderSearchModel { ID = model.ID });//возвращает null
|
||||
if (model != null&& order!=null)
|
||||
{
|
||||
order.ProductList = model.ProductList;
|
||||
order.Sum = model.Sum;
|
||||
order.Sum += model.Sum;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -1,18 +1,22 @@
|
||||
using ElectronicsShopContracts.BindingModels;
|
||||
using ElectronicsShopContracts.BusinessLogicContracts;
|
||||
using ElectronicsShopContracts.SearchModels;
|
||||
using ElectronicsShopContracts.ViewModels;
|
||||
using ElectronicsShopDataModels.Models;
|
||||
using ElectronicsShopUserApp.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace ElectronicsShopUserApp.Controllers {
|
||||
public class HomeController : Controller {
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
//private readonly IOrderLogic _order;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger) {
|
||||
public HomeController(ILogger<HomeController> logger/*, IOrderLogic orderLogic*/) {
|
||||
_logger = logger;
|
||||
//_order = orderLogic;
|
||||
}
|
||||
|
||||
public IActionResult Index() {
|
||||
@ -92,12 +96,13 @@ namespace ElectronicsShopUserApp.Controllers {
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult CreateOrder() {
|
||||
ViewBag.Products = APIClient.GetRequset<List<ProductViewModel>>("api/main/getproducts");
|
||||
public IActionResult CreateOrders() {
|
||||
|
||||
ViewBag.Products =APIClient.GetRequset<List<ProductViewModel>>("api/main/getproducts");
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateOrder(OrderBindingModel order) {
|
||||
public void CreateOrders(OrderBindingModel order) {
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñóäà ïîïàëè? Ñóäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
@ -122,7 +127,7 @@ namespace ElectronicsShopUserApp.Controllers {
|
||||
public double Calc(int count, int product)
|
||||
{
|
||||
var prod =
|
||||
APIClient.GetRequset<ProductViewModel>($"api/main/getproduct?productID={product}"
|
||||
APIClient.GetRequset<ProductViewModel>($"api/main/getproduct?_productid={product}"
|
||||
);
|
||||
return count * (prod?.Price ?? 1);
|
||||
}
|
||||
@ -133,7 +138,7 @@ namespace ElectronicsShopUserApp.Controllers {
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void AddProduct(int count)
|
||||
public void AddProduct(int count/*, int product*/)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
@ -143,11 +148,7 @@ namespace ElectronicsShopUserApp.Controllers {
|
||||
{
|
||||
throw new Exception("Êîëè÷åñòâî è ñóììà äîëæíû áûòü áîëüøå 0");
|
||||
}
|
||||
APIClient.PostRequest("api/main/addproduct", new OrderSearchModel
|
||||
{
|
||||
ID = 1,
|
||||
ClientID=APIClient.Client.ID,
|
||||
});
|
||||
|
||||
Response.Redirect("CreateOrder");
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Product:</div>
|
||||
<div class="col-4">Продукты:</div>
|
||||
<div class="col-8">
|
||||
<select id="product" name="product" class="form-control">
|
||||
@foreach (var product in ViewBag.Products)
|
||||
|
@ -2,19 +2,9 @@
|
||||
|
||||
@model OrderViewModel
|
||||
@{
|
||||
ViewData["Title"] = "Create Order";
|
||||
ViewData["Title"] = "CreateOrders";
|
||||
}
|
||||
|
||||
|
||||
<div class="row">
|
||||
<p>
|
||||
<a asp-action="AddProduct">Добавть продукт в корзину</a>
|
||||
</p>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Создать заказ" class="btn btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Корзина</h1>
|
||||
@{
|
@ -17,12 +17,9 @@
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
<p>
|
||||
<a asp-action="CreateOrder">Создать заказ</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<th>
|
||||
<tr>
|
||||
<th>
|
||||
Номер заказа
|
||||
</th>
|
||||
@ -32,7 +29,7 @@
|
||||
<th>
|
||||
Сумма
|
||||
</th>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model) {
|
||||
|
@ -31,6 +31,12 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="CreateOrders">Создание корзин</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="AddProduct">Каталог</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user