Настоящая свобода начинается по ту сторону отчаяния.
This commit is contained in:
parent
939cba359a
commit
44b11867c9
@ -1,4 +1,4 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SushiBarClientApp.Models;
|
||||
using SushiBarContracts.BindingModel;
|
||||
using SushiBarContracts.BindingModels;
|
||||
@ -37,14 +37,15 @@ namespace SushiBarClientApp.Controllers
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñóäà ïîïàëè? Ñóäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(login) ||
|
||||
string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio))
|
||||
{
|
||||
throw new Exception("Ââåäèòå ëîãèí, ïàðîëü è ÔÈÎ");
|
||||
throw new Exception("Введите логин, пароль и ФИО");
|
||||
}
|
||||
APIClient.PostRequest("api/client/updatedata", new ClientBindingModel
|
||||
APIClient.PostRequest("api/client/updatedata", new
|
||||
ClientBindingModel
|
||||
{
|
||||
Id = APIClient.Client.Id,
|
||||
ClientFIO = fio,
|
||||
@ -56,12 +57,14 @@ namespace SushiBarClientApp.Controllers
|
||||
APIClient.Client.Password = password;
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None,
|
||||
NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
return View(new ErrorViewModel
|
||||
{
|
||||
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier
|
||||
RequestId =
|
||||
Activity.Current?.Id ?? HttpContext.TraceIdentifier
|
||||
});
|
||||
}
|
||||
[HttpGet]
|
||||
@ -72,14 +75,16 @@ namespace SushiBarClientApp.Controllers
|
||||
[HttpPost]
|
||||
public void Enter(string login, string password)
|
||||
{
|
||||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
||||
if (string.IsNullOrEmpty(login) ||
|
||||
string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new Exception("Ââåäèòå ëîãèí è ïàðîëü");
|
||||
throw new Exception("Введите логин и пароль");
|
||||
}
|
||||
APIClient.Client = APIClient.GetRequest<ClientViewModel>($"api/client/login?login={login}&password={password}");
|
||||
APIClient.Client =
|
||||
APIClient.GetRequest<ClientViewModel>($"api/client/login?login={login}&password={password}");
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Íåâåðíûé ëîãèí/ïàðîëü");
|
||||
throw new Exception("Неверный логин/пароль");
|
||||
}
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
@ -91,11 +96,13 @@ namespace SushiBarClientApp.Controllers
|
||||
[HttpPost]
|
||||
public void Register(string login, string password, string fio)
|
||||
{
|
||||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio))
|
||||
if (string.IsNullOrEmpty(login) ||
|
||||
string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio))
|
||||
{
|
||||
throw new Exception("Ââåäèòå ëîãèí, ïàðîëü è ÔÈÎ");
|
||||
throw new Exception("Введите логин, пароль и ФИО");
|
||||
}
|
||||
APIClient.PostRequest("api/client/register", new ClientBindingModel
|
||||
APIClient.PostRequest("api/client/register", new
|
||||
ClientBindingModel
|
||||
{
|
||||
ClientFIO = fio,
|
||||
Email = login,
|
||||
@ -107,7 +114,8 @@ namespace SushiBarClientApp.Controllers
|
||||
[HttpGet]
|
||||
public IActionResult Create()
|
||||
{
|
||||
ViewBag.Sushis = APIClient.GetRequest<List<SushiViewModel>>("api/main/getsushilist");
|
||||
ViewBag.Sushis =
|
||||
APIClient.GetRequest<List<SushiViewModel>>("api/main/getsushilist");
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
@ -115,11 +123,11 @@ namespace SushiBarClientApp.Controllers
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñóäà ïîïàëè? Ñóäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
if (count <= 0)
|
||||
{
|
||||
throw new Exception("Êîëè÷åñòâî è ñóììà äîëæíû áûòü áîëüøå 0");
|
||||
throw new Exception("Количество и сумма должны быть больше 0");
|
||||
}
|
||||
APIClient.PostRequest("api/main/createorder", new OrderBindingModel
|
||||
{
|
||||
@ -133,9 +141,12 @@ namespace SushiBarClientApp.Controllers
|
||||
[HttpPost]
|
||||
public double Calc(int count, int sushi)
|
||||
{
|
||||
var prod = APIClient.GetRequest<SushiViewModel>($"api/main/getsushi?sushiId={sushi}"
|
||||
var prod =
|
||||
APIClient.GetRequest<SushiViewModel>($"api/main/getsushi?sushiId={sushi}"
|
||||
);
|
||||
return count * (prod?.Price ?? 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user