2023-05-18 23:42:48 +04:00
|
|
|
|
using CaseAccountingContracts.BindingModels;
|
|
|
|
|
using CaseAccountingContracts.ViewModels;
|
|
|
|
|
using CaseAccountingCustomerView.Models;
|
|
|
|
|
using CaseAccountingDataModels.Enum;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
|
|
namespace CaseAccountingCustomerView.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class HomeController : Controller
|
|
|
|
|
{
|
|
|
|
|
public HomeController() { }
|
|
|
|
|
|
|
|
|
|
public IActionResult Index()
|
|
|
|
|
{
|
|
|
|
|
if (APIUser.User == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Login");
|
|
|
|
|
}
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult Login()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult Registration()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Login(string login, string password)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Введите логин и пароль");
|
|
|
|
|
}
|
2023-05-19 02:29:30 +04:00
|
|
|
|
APIUser.User = APIUser.GetRequest<UserViewModel>($"api/user/login?login={login}&password={password}&role={Role.Customer}");
|
2023-05-18 23:42:48 +04:00
|
|
|
|
if (APIUser.User == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Неверный логин/пароль");
|
|
|
|
|
}
|
|
|
|
|
Response.Redirect("Index");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Registration(string login, string password)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Введите логин и пароль");
|
|
|
|
|
}
|
|
|
|
|
APIUser.PostRequest("api/user/register", new UserBindingModel
|
|
|
|
|
{
|
|
|
|
|
Login = login,
|
|
|
|
|
Password = password,
|
2023-05-19 02:29:30 +04:00
|
|
|
|
Role = Role.Customer
|
|
|
|
|
});
|
2023-05-18 23:42:48 +04:00
|
|
|
|
Response.Redirect("Login");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult Lawyers( )
|
|
|
|
|
{
|
|
|
|
|
if (APIUser.User == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
ViewBag.Lawyers = APIUser.GetRequest<List<LawyerViewModel>>
|
2023-05-19 13:20:14 +04:00
|
|
|
|
($"api/lawyer/getallbyuser?userId={APIUser.User.Id}");
|
2023-05-18 23:42:48 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult Specializations()
|
|
|
|
|
{
|
|
|
|
|
if (APIUser.User == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
ViewBag.Specializations = APIUser.GetRequest<List<SpecializationViewModel>>
|
2023-05-19 13:20:14 +04:00
|
|
|
|
($"api/specialization/getallbyuser?userId={APIUser.User.Id}");
|
2023-05-18 23:42:48 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult Contracts()
|
|
|
|
|
{
|
|
|
|
|
if (APIUser.User == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
ViewBag.Contracts = APIUser.GetRequest<List<ContractViewModel>>
|
2023-05-19 13:20:14 +04:00
|
|
|
|
($"api/contract/getallbyuser?userId={APIUser.User.Id}");
|
2023-05-18 23:42:48 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
|
|
|
|
public IActionResult Error()
|
|
|
|
|
{
|
|
|
|
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
|
|
|
|
}
|
2023-05-20 01:21:33 +04:00
|
|
|
|
|
|
|
|
|
[HttpPost]
|
2023-05-23 00:11:38 +04:00
|
|
|
|
public int[]? SpecializationCaselist([FromBody] LawyerHearingListBindingModel listModel)
|
2023-05-20 01:21:33 +04:00
|
|
|
|
{
|
|
|
|
|
if (APIUser.User == null)
|
|
|
|
|
{
|
|
|
|
|
return Array.Empty<int>();
|
|
|
|
|
}
|
|
|
|
|
byte[]? file = APIUser.PostRequestWithResult<LawyerHearingListBindingModel, byte[]>
|
2023-05-23 00:11:38 +04:00
|
|
|
|
("api/reportprovider/specializationcaselist", listModel);
|
2023-05-20 01:21:33 +04:00
|
|
|
|
return file!.Select(b => (int)b).ToArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult HearingLawyerList()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
2023-05-18 23:42:48 +04:00
|
|
|
|
}
|
|
|
|
|
}
|