2023-04-07 17:08:15 +04:00
|
|
|
|
using BankContracts.BindingModels;
|
|
|
|
|
using BankContracts.ViewModels;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2023-04-07 11:58:10 +04:00
|
|
|
|
using OperatorApp.Models;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
|
|
namespace OperatorApp.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class HomeController : Controller
|
|
|
|
|
{
|
|
|
|
|
private readonly ILogger<HomeController> _logger;
|
|
|
|
|
|
|
|
|
|
public HomeController(ILogger<HomeController> logger)
|
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult Index()
|
|
|
|
|
{
|
2023-04-07 17:08:15 +04:00
|
|
|
|
if (APIClient.Operator == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
return View(APIClient.GetRequest<List<DealViewModel>>($"api/deal/getdeals?operatorId={APIClient.Operator.Id}"));
|
2023-04-07 11:58:10 +04:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-07 17:08:15 +04:00
|
|
|
|
[HttpGet]
|
2023-04-07 11:58:10 +04:00
|
|
|
|
public IActionResult Privacy()
|
|
|
|
|
{
|
2023-04-07 17:08:15 +04:00
|
|
|
|
if (APIClient.Operator == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
return View(APIClient.Operator);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Privacy(string login, string password, string lastname, string firstname, string middleName)
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Operator == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(lastname) || string.IsNullOrEmpty(firstname) || string.IsNullOrEmpty(middleName))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Введите логин, пароль и ФИО");
|
|
|
|
|
}
|
|
|
|
|
APIClient.PostRequest("api/operator/updateoperator", new OperatorBindingModel
|
|
|
|
|
{
|
|
|
|
|
Id = APIClient.Operator.Id,
|
|
|
|
|
LastName = lastname,
|
|
|
|
|
FirstName = firstname,
|
|
|
|
|
MiddleName = middleName,
|
|
|
|
|
Login = login,
|
|
|
|
|
Password = password
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
APIClient.Operator.LastName = lastname;
|
|
|
|
|
APIClient.Operator.FirstName = firstname;
|
|
|
|
|
APIClient.Operator.MiddleName = middleName;
|
|
|
|
|
APIClient.Operator.Login = login;
|
|
|
|
|
APIClient.Operator.Password = password;
|
|
|
|
|
Response.Redirect("Index");
|
2023-04-07 11:58:10 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
|
|
|
|
public IActionResult Error()
|
|
|
|
|
{
|
|
|
|
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
|
|
|
|
}
|
2023-04-07 17:08:15 +04:00
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public IActionResult Enter()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Enter(string login, string password)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Введите логин и пароль");
|
|
|
|
|
}
|
|
|
|
|
APIClient.Operator = APIClient.GetRequest<OperatorViewModel>($"api/operator/login?login={login}&password={password}");
|
|
|
|
|
if (APIClient.Operator == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Неверный логин/пароль");
|
|
|
|
|
}
|
|
|
|
|
Response.Redirect("Index");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public IActionResult Register()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Register(string login, string password, string lastname, string firstname, string middleName)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(lastname) || string.IsNullOrEmpty(firstname) || string.IsNullOrEmpty(middleName))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Введите логин, пароль и ФИО");
|
|
|
|
|
}
|
2023-04-07 18:04:25 +04:00
|
|
|
|
APIClient.PostRequest("api/operator/createoperator", new OperatorBindingModel
|
2023-04-07 17:08:15 +04:00
|
|
|
|
{
|
|
|
|
|
LastName = lastname,
|
|
|
|
|
FirstName = firstname,
|
|
|
|
|
MiddleName = middleName,
|
|
|
|
|
Login = login,
|
|
|
|
|
Password = password
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("Enter");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public IActionResult CreateDeal()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateDeal(int clientid)
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Operator == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
|
|
|
|
}
|
2023-04-07 18:20:50 +04:00
|
|
|
|
APIClient.PostRequest("api/deal/createdeal", new DealBindingModel
|
2023-04-07 17:08:15 +04:00
|
|
|
|
{
|
|
|
|
|
ClientId = clientid,
|
|
|
|
|
OperatorId = APIClient.Operator.Id,
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("Index");
|
|
|
|
|
}
|
2023-04-07 11:58:10 +04:00
|
|
|
|
}
|
|
|
|
|
}
|