продукты
This commit is contained in:
parent
b626bfda7d
commit
6aa55f1c11
@ -8,6 +8,6 @@ namespace ComputerHardwareStoreContracts.BindingModels
|
|||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; set; } = new();
|
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; set; } = new();
|
||||||
public IStoreKeeperModel StoreKeeper { get; set; }
|
public int StoreKeeperId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,6 @@ namespace ComputerHardwareStoreContracts.ViewModels
|
|||||||
[DisplayName("Цена")]
|
[DisplayName("Цена")]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; set; } = new();
|
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; set; } = new();
|
||||||
public IStoreKeeperModel StoreKeeper { get; set; }
|
public int StoreKeeperId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
{
|
{
|
||||||
string Name { get; }
|
string Name { get; }
|
||||||
double Price { get; }
|
double Price { get; }
|
||||||
public IStoreKeeperModel StoreKeeper { get; }
|
public int StoreKeeperId { get; }
|
||||||
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; }
|
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,7 @@ namespace ComputerHardwareStoreDatabaseImplement.Models
|
|||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
[Required]
|
[Required]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
[NotMapped]
|
public int StoreKeeperId { get; set; }
|
||||||
IStoreKeeperModel IProductModel.StoreKeeper => StoreKeeper;
|
|
||||||
public virtual StoreKeeper StoreKeeper {get; set;} = new();
|
public virtual StoreKeeper StoreKeeper {get; set;} = new();
|
||||||
private Dictionary<int, (IComponentModel, int)>? _productComponents = null;
|
private Dictionary<int, (IComponentModel, int)>? _productComponents = null;
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
@ -65,7 +64,7 @@ namespace ComputerHardwareStoreDatabaseImplement.Models
|
|||||||
Name = Name,
|
Name = Name,
|
||||||
Price = Price,
|
Price = Price,
|
||||||
ProductComponents = ProductComponents,
|
ProductComponents = ProductComponents,
|
||||||
StoreKeeper = StoreKeeper,
|
StoreKeeperId = StoreKeeperId,
|
||||||
};
|
};
|
||||||
|
|
||||||
public static void UpdateComponents(ComputerHardwareStoreDBContext context, ProductBindingModel model)
|
public static void UpdateComponents(ComputerHardwareStoreDBContext context, ProductBindingModel model)
|
||||||
|
@ -18,47 +18,8 @@ namespace StoreKeeperClient.Controllers
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
{
|
{
|
||||||
if (APIClient.Client == null)
|
return View();
|
||||||
{
|
}
|
||||||
return Redirect("~/Home/Enter");
|
|
||||||
}
|
|
||||||
|
|
||||||
return View(APIClient.GetRequest<List<PurchaseViewModel>>($"api/main/getpurchases?storekeeperId={APIClient.Client.Id}"));
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
public IActionResult Privacy()
|
|
||||||
{
|
|
||||||
if (APIClient.Client == null)
|
|
||||||
{
|
|
||||||
return Redirect("~/Home/Enter");
|
|
||||||
}
|
|
||||||
return View(APIClient.Client);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost]
|
|
||||||
public void Privacy(string login, string password, string fio)
|
|
||||||
{
|
|
||||||
if (APIClient.Client == null)
|
|
||||||
{
|
|
||||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio))
|
|
||||||
{
|
|
||||||
throw new Exception("Введите логин, пароль и ФИО");
|
|
||||||
}
|
|
||||||
APIClient.PostRequest("api/storekeeper/updatedata", new StoreKeeperBindingModel
|
|
||||||
{
|
|
||||||
Id = APIClient.Client.Id,
|
|
||||||
Name = fio,
|
|
||||||
Login = login,
|
|
||||||
Password = password
|
|
||||||
});
|
|
||||||
APIClient.Client.Name = fio;
|
|
||||||
APIClient.Client.Login = login;
|
|
||||||
APIClient.Client.Password = password;
|
|
||||||
Response.Redirect("Index");
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult Enter()
|
public IActionResult Enter()
|
||||||
@ -78,7 +39,7 @@ namespace StoreKeeperClient.Controllers
|
|||||||
{
|
{
|
||||||
throw new Exception("Неверные почта и/или пароль");
|
throw new Exception("Неверные почта и/или пароль");
|
||||||
}
|
}
|
||||||
Response.Redirect("Index");
|
Response.Redirect("Home/Index");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,6 +65,7 @@ namespace StoreKeeperClient.Controllers
|
|||||||
Response.Redirect("Enter");
|
Response.Redirect("Enter");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult AddBuildToPurchase()
|
public IActionResult AddBuildToPurchase()
|
||||||
{
|
{
|
||||||
@ -195,13 +157,103 @@ namespace StoreKeeperClient.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult ProductsList()
|
public IActionResult Products()
|
||||||
{
|
{
|
||||||
if (APIClient.Client == null)
|
if (APIClient.Client == null)
|
||||||
{
|
{
|
||||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||||
}
|
}
|
||||||
return View(new List<BuildViewModel>());
|
return View(new List<ProductViewModel>());
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult CreateProduct()
|
||||||
|
{
|
||||||
|
if (APIClient.Client == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>($"api/component/getcomponents?userId={APIClient.Client.Id}");
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void CreateProduct([FromBody] ProductBindingModel productModel)
|
||||||
|
{
|
||||||
|
if (APIClient.Client == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(productModel.Name))
|
||||||
|
{
|
||||||
|
throw new Exception("Название не должно быть пустым");
|
||||||
|
}
|
||||||
|
if (productModel.Price <= 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Цена должна быть больше 0");
|
||||||
|
}
|
||||||
|
productModel.StoreKeeperId = APIClient.Client.Id;
|
||||||
|
APIClient.PostRequest("api/product/createproduct", productModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult UpdateProduct(int productid)
|
||||||
|
{
|
||||||
|
if (APIClient.Client == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||||
|
}
|
||||||
|
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>($"api/component/getcomponents?userId={APIClient.Client.Id}");
|
||||||
|
return View(productid);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void UpdateProduct([FromBody] ProductBindingModel productModel)
|
||||||
|
{
|
||||||
|
if (APIClient.Client == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(productModel.Name))
|
||||||
|
{
|
||||||
|
throw new Exception("Название не должно быть пустым");
|
||||||
|
}
|
||||||
|
if (productModel.Price <= 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Цена должна быть больше 0");
|
||||||
|
}
|
||||||
|
productModel.StoreKeeperId = APIClient.Client.Id;
|
||||||
|
APIClient.PostRequest("api/product/updatedata", productModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void DeleteGood(int model)
|
||||||
|
{
|
||||||
|
if (APIClient.Client == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||||
|
}
|
||||||
|
if (model <= 0)
|
||||||
|
{
|
||||||
|
throw new Exception($"Идентификатор товара не может быть меньше или равен 0");
|
||||||
|
}
|
||||||
|
APIClient.PostRequest("api/product/deleteproduct", new ProductBindingModel
|
||||||
|
{
|
||||||
|
Id = model
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public ProductViewModel? GetProduct(int Id)
|
||||||
|
{
|
||||||
|
if (APIClient.Client == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||||
|
}
|
||||||
|
if (Id <= 0)
|
||||||
|
{
|
||||||
|
throw new Exception($"Идентификатор товара не может быть меньше или равен 0");
|
||||||
|
}
|
||||||
|
var result = APIClient.GetRequest<ProductViewModel>($"api/product/getproduct?id={Id}");
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@ -234,16 +286,6 @@ namespace StoreKeeperClient.Controllers
|
|||||||
return View(new List<PurchaseViewModel>());
|
return View(new List<PurchaseViewModel>());
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
public IActionResult PurchaseUpdate()
|
|
||||||
{
|
|
||||||
if (APIClient.Client == null)
|
|
||||||
{
|
|
||||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
|
||||||
}
|
|
||||||
return View();
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult Report()
|
public IActionResult Report()
|
||||||
{
|
{
|
||||||
|
@ -20,6 +20,6 @@ app.UseAuthorization();
|
|||||||
|
|
||||||
app.MapControllerRoute(
|
app.MapControllerRoute(
|
||||||
name: "default",
|
name: "default",
|
||||||
pattern: "{controller=Home}/{action=Index}/{id?}");
|
pattern: "{controller=Home}/{action=Enter}/{id?}");
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
@ -34,3 +34,96 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
@section Scripts
|
||||||
|
{
|
||||||
|
<script>
|
||||||
|
let list = [];
|
||||||
|
const name = document.getElementById("name");
|
||||||
|
const submitComponentBtn = document.getElementById("savecomponent");
|
||||||
|
const saveBtn = document.getElementById("createproduct");
|
||||||
|
const countElem = document.getElementById("count");
|
||||||
|
const resultTable = document.getElementById("result");
|
||||||
|
const totalPrice = document.getElementById("price");
|
||||||
|
|
||||||
|
submitComponentBtn.addEventListener("click", () => {
|
||||||
|
console.log('try to add component')
|
||||||
|
var count = $('#count').val();
|
||||||
|
var component = $('#component').val();
|
||||||
|
if (component && count && count > 0) {
|
||||||
|
$.ajax({
|
||||||
|
method: "GET",
|
||||||
|
url: `/Storekeeper/GetComponent`,
|
||||||
|
data: { Id: component },
|
||||||
|
success: function (result) {
|
||||||
|
let flag = false
|
||||||
|
if (list.length > 0) {
|
||||||
|
list.forEach((elem) => {
|
||||||
|
if (elem.component.id === parseInt(result.id)) {
|
||||||
|
console.log('component already added')
|
||||||
|
flag = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (!flag) list.push({ component: result, count: count })
|
||||||
|
reloadTable()
|
||||||
|
countElem.value = '1'
|
||||||
|
}
|
||||||
|
}).fail(function (xhr, textStatus, errorThrown) {
|
||||||
|
alert(xhr.responseText);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
saveBtn.addEventListener("click", () => {
|
||||||
|
console.log('try to add product')
|
||||||
|
if (list.length == 0) {
|
||||||
|
alert('failed add product. components are empty')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let components = []
|
||||||
|
let counts = []
|
||||||
|
list.forEach((x) => {
|
||||||
|
components.push(x.component);
|
||||||
|
counts.push(parseInt(x.count))
|
||||||
|
})
|
||||||
|
$.ajax(
|
||||||
|
{
|
||||||
|
url: `/Storekeeper/CreateProduct`,
|
||||||
|
type: 'POST',
|
||||||
|
contentType: 'application/json',
|
||||||
|
data: JSON.stringify({
|
||||||
|
"Name": name.value, "Price": parseFloat(totalPrice.value),
|
||||||
|
"ProductComponentsComponents": components, "ProductComponentsCounts": counts
|
||||||
|
})
|
||||||
|
}
|
||||||
|
).done(() => window.location.href = '/Storekeeper/Products')
|
||||||
|
.fail(function (xhr, textStatus, errorThrown) {
|
||||||
|
alert(xhr.responseText);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
function reloadTable() {
|
||||||
|
resultTable.innerHTML = ''
|
||||||
|
let price = 0;
|
||||||
|
let count = 0;
|
||||||
|
list.forEach((elem) => {
|
||||||
|
resultTable.innerHTML += `<tr><td>${elem.component.componentName}</td><td>${elem.component.cost}</td><td>${elem.count}</td><td>${Math.round(elem.component.cost * elem.count * 100) / 100}</td><td> \
|
||||||
|
<div> \
|
||||||
|
<button onclick="deleteComponent(${count})" type="button" class="btn btn-danger"> \
|
||||||
|
<i class="fa fa-trash" aria-hidden="true"></i> \
|
||||||
|
</button> \
|
||||||
|
</div><td/></tr>`
|
||||||
|
count++;
|
||||||
|
price += elem.component.cost * elem.count
|
||||||
|
})
|
||||||
|
totalPrice.value = Math.round(price * 100) / 100
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteComponent(id) {
|
||||||
|
list = list.filter(value => value.component.componentName != resultTable.rows[id].cells[0].innerText)
|
||||||
|
reloadTable()
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
}
|
@ -1,5 +1,4 @@
|
|||||||
@using ComputerHardwareStoreContracts.ViewModels
|
@using ComputerHardwareStoreContracts.ViewModels
|
||||||
@model List<OrderViewModel>
|
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Home Page";
|
ViewData["Title"] = "Home Page";
|
||||||
}
|
}
|
||||||
@ -11,54 +10,8 @@
|
|||||||
@{
|
@{
|
||||||
if (Model == null)
|
if (Model == null)
|
||||||
{
|
{
|
||||||
<h3 class="display-4">Авторизируйтесь</h3>
|
<h3 class="display-4">Добро пожаловать</h3>
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
<p>
|
|
||||||
<a asp-action="Create">Создать заказ</a>
|
|
||||||
</p>
|
|
||||||
<table class="table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>
|
|
||||||
Номер
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
Изделие
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
Дата создания
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
Количество
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
Сумма
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
Статус
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
@foreach (var item in Model)
|
|
||||||
{
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
@Html.DisplayFor(modelItem => item.Id)
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
@Html.DisplayFor(modelItem => item.DateCreate)
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
@Html.DisplayFor(modelItem => item.Sum)
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
@Html.DisplayFor(modelItem => item.Status)
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
@ -7,52 +7,53 @@
|
|||||||
<h1 class="display-4">Товары</h1>
|
<h1 class="display-4">Товары</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
@{
|
@{
|
||||||
if (Model == null)
|
if (Model == null)
|
||||||
{
|
{
|
||||||
<h3 class="display-4">Надо войти!</h3>
|
<h3 class="display-4">Надо войти!</h3>
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
<p>
|
<p>
|
||||||
<a class="text-decoration-none me-3 text-black h5" asp-action="CreateProduct">Создать товар</a>
|
<a class="text-decoration-none me-3 text-black h5" asp-action="CreateProduct">Создать товар</a>
|
||||||
<a class="text-decoration-none me-3 text-black h5" asp-action="UpdateProduct">Изменить товар</a>
|
<a class="text-decoration-none me-3 text-black h5" asp-action="UpdateProduct">Изменить товар</a>
|
||||||
<a class="text-decoration-none text-black h5" asp-action="DeleteProduct">Удалить товар</a>
|
<a class="text-decoration-none text-black h5" asp-action="DeleteProduct">Удалить товар</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<table class="productTable">
|
<table class="productTable">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th>
|
||||||
Номер
|
Номер
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
Название
|
Название
|
||||||
</th>
|
</th>
|
||||||
<th>
|
|
||||||
Цена
|
|
||||||
</th>
|
|
||||||
|
|
||||||
</tr>
|
<th>
|
||||||
</thead>
|
Цена
|
||||||
<tbody>
|
</th>
|
||||||
<tbody>
|
|
||||||
@foreach (var Product in Model)
|
</tr>
|
||||||
{
|
</thead>
|
||||||
<tr>
|
<tbody>
|
||||||
<td>
|
<tbody>
|
||||||
@Html.DisplayFor(modelItem => Product.Id)
|
@foreach (var Product in Model)
|
||||||
</td>
|
{
|
||||||
<td>
|
<tr>
|
||||||
@Html.DisplayFor(modelItem => Product.Name)
|
<td>
|
||||||
</td>
|
@Html.DisplayFor(modelItem => Product.Id)
|
||||||
<td>
|
</td>
|
||||||
@Html.DisplayFor(modelItem => Product.Price)
|
<td>
|
||||||
</td>
|
@Html.DisplayFor(modelItem => Product.Name)
|
||||||
</tr>
|
</td>
|
||||||
}
|
<td>
|
||||||
</tbody>
|
@Html.DisplayFor(modelItem => Product.Price)
|
||||||
</tbody>
|
</td>
|
||||||
</table>
|
</tr>
|
||||||
}
|
}
|
||||||
|
</tbody>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -19,9 +19,6 @@
|
|||||||
</button>
|
</button>
|
||||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||||
<ul class="navbar-nav flex-grow-1">
|
<ul class="navbar-nav flex-grow-1">
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Components">Комплектующие</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Components">Комплектующие</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using ComputerHardwareStoreContracts.ViewModels;
|
using ComputerHardwareStoreContracts.BindingModels;
|
||||||
|
using ComputerHardwareStoreContracts.ViewModels;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using VendorClient.Models;
|
using VendorClient.Models;
|
||||||
@ -17,13 +18,46 @@ namespace VendorClient.Controllers
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
{
|
{
|
||||||
return View();
|
if (APIClient.Vendor == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
|
||||||
|
return View(APIClient.Vendor);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult Privacy()
|
public IActionResult Privacy()
|
||||||
{
|
{
|
||||||
return View();
|
if (APIClient.Vendor == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
return View(APIClient.Vendor);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void Privacy(string login, string password, string fio)
|
||||||
|
{
|
||||||
|
if (APIClient.Vendor == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio))
|
||||||
|
{
|
||||||
|
throw new Exception("Введите логин, пароль и ФИО");
|
||||||
|
}
|
||||||
|
APIClient.PostRequest("api/vendor/updatedata", new VendorBindingModel
|
||||||
|
{
|
||||||
|
Id = APIClient.Vendor.Id,
|
||||||
|
Name = fio,
|
||||||
|
Login = login,
|
||||||
|
Password = password
|
||||||
|
});
|
||||||
|
APIClient.Vendor.Name = fio;
|
||||||
|
APIClient.Vendor.Login = login;
|
||||||
|
APIClient.Vendor.Password = password;
|
||||||
|
Response.Redirect("Index");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@ -32,13 +66,46 @@ namespace VendorClient.Controllers
|
|||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void Enter(string login, string password)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
||||||
|
{
|
||||||
|
throw new Exception("Введите почту и пароль");
|
||||||
|
}
|
||||||
|
APIClient.Vendor = APIClient.GetRequest<VendorViewModel>($"api/vendor/login?login={login}&password={password}");
|
||||||
|
if (APIClient.Vendor == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Неверные почта и/или пароль");
|
||||||
|
}
|
||||||
|
Response.Redirect("Index");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult Register()
|
public IActionResult Register()
|
||||||
{
|
{
|
||||||
return View();
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
return View();
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void Register(string name, string login, string password)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(name) || string.IsNullOrEmpty(password))
|
||||||
|
{
|
||||||
|
throw new Exception("Введите логин, name, пароль");
|
||||||
|
}
|
||||||
|
APIClient.PostRequest("api/vendor/register", new VendorBindingModel
|
||||||
|
{
|
||||||
|
Name = name,
|
||||||
|
Login = login,
|
||||||
|
Password = password,
|
||||||
|
});
|
||||||
|
Response.Redirect("Enter");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
public IActionResult AddBuildToPurchase()
|
public IActionResult AddBuildToPurchase()
|
||||||
{
|
{
|
||||||
return View();
|
return View();
|
||||||
|
Loading…
Reference in New Issue
Block a user