2023-05-18 23:32:19 +04:00
|
|
|
|
using CaseAccountingContracts.BindingModels;
|
|
|
|
|
using CaseAccountingContracts.ViewModels;
|
|
|
|
|
using CaseAccountingDataModels.Enum;
|
|
|
|
|
using CaseAccountingProviderView.Models;
|
2023-05-17 20:17:29 +04:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
|
|
namespace CaseAccountingProviderView.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class HomeController : Controller
|
|
|
|
|
{
|
|
|
|
|
private readonly ILogger<HomeController> _logger;
|
|
|
|
|
|
|
|
|
|
public HomeController(ILogger<HomeController> logger)
|
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult Index()
|
|
|
|
|
{
|
2023-05-18 23:32:19 +04:00
|
|
|
|
if (APIUser.User == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Login");
|
|
|
|
|
}
|
2023-05-17 20:17:29 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-18 23:32:19 +04:00
|
|
|
|
public IActionResult Login()
|
2023-05-17 20:17:29 +04:00
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-18 23:32:19 +04:00
|
|
|
|
public IActionResult Registration()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-20 00:24:04 +04:00
|
|
|
|
public IActionResult SpecializationCaselist()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public int[]? SpecializationCaselist([FromBody] CaseSpecializationListBindingModel listModel)
|
|
|
|
|
{
|
|
|
|
|
if (APIUser.User == null)
|
|
|
|
|
{
|
|
|
|
|
return Array.Empty<int>();
|
|
|
|
|
}
|
|
|
|
|
byte[]? file = APIUser.PostRequestWithResult<CaseSpecializationListBindingModel, byte[]>
|
|
|
|
|
("api/reportprovider/specializationcaselist", listModel);
|
|
|
|
|
return file!.Select(b => (int)b).ToArray();
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-20 03:13:10 +04:00
|
|
|
|
public IActionResult GetReport()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public List<ReportHearingLawyerViewModel>? GetReport([FromBody] ReportBindingModel reportModel)
|
|
|
|
|
{
|
|
|
|
|
if (APIUser.User == null)
|
|
|
|
|
{
|
|
|
|
|
return new();
|
|
|
|
|
}
|
|
|
|
|
reportModel.UserId = APIUser.User.Id;
|
|
|
|
|
reportModel.UserEmail = APIUser.User.Login;
|
|
|
|
|
List<ReportHearingLawyerViewModel>? list = APIUser.PostRequestWithResult<ReportBindingModel, List<ReportHearingLawyerViewModel>>
|
|
|
|
|
("api/reportprovider/getreportdata", reportModel);
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void SendByMailStatusReport([FromBody] ReportBindingModel reportModel)
|
|
|
|
|
{
|
|
|
|
|
if (APIUser.User == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
reportModel.UserId = APIUser.User.Id;
|
|
|
|
|
reportModel.UserEmail = APIUser.User.Login;
|
|
|
|
|
APIUser.PostRequest("api/reportprovider/sendbymailstatusreport", reportModel);
|
|
|
|
|
}
|
2023-05-20 00:24:04 +04:00
|
|
|
|
|
|
|
|
|
[HttpPost]
|
2023-05-18 23:32:19 +04:00
|
|
|
|
public void Login(string login, string password)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Введите логин и пароль");
|
|
|
|
|
}
|
|
|
|
|
APIUser.User = APIUser.GetRequest<UserViewModel>($"api/user/login?login={login}&password={password}&role={Role.Provider}");
|
|
|
|
|
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,
|
|
|
|
|
Role = Role.Provider
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("Login");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult Cases()
|
|
|
|
|
{
|
|
|
|
|
if (APIUser.User == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
ViewBag.Cases = APIUser.GetRequest<List<CaseViewModel>>
|
|
|
|
|
($"api/case/getallbyuser?userId={APIUser.User.Id}");
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult Deals()
|
|
|
|
|
{
|
|
|
|
|
if (APIUser.User == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
ViewBag.Deals = APIUser.GetRequest<List<DealViewModel>>
|
|
|
|
|
($"api/deal/getallbyuser?userId={APIUser.User.Id}");
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult Hearings()
|
|
|
|
|
{
|
|
|
|
|
if (APIUser.User == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
ViewBag.Hearings = APIUser.GetRequest<List<HearingViewModel>>
|
|
|
|
|
($"api/hearing/getallbyuser?userId={APIUser.User.Id}");
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-17 20:17:29 +04:00
|
|
|
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
|
|
|
|
public IActionResult Error()
|
|
|
|
|
{
|
|
|
|
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|