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