diff --git a/LawFim/LawFirmExecutorApp/APIClient.cs b/LawFim/LawFirmExecutorApp/APIClient.cs index 3868c09..6f338fa 100644 --- a/LawFim/LawFirmExecutorApp/APIClient.cs +++ b/LawFim/LawFirmExecutorApp/APIClient.cs @@ -8,7 +8,7 @@ namespace LawFirmExecutorApp public class APIClient { private static readonly HttpClient _client = new(); - public static ExecutorViewModel? Executor { get; set; } = null; + public static ExecutorViewModel? User { get; set; } = null; public static void Connect(IConfiguration configuration) { _client.BaseAddress = new Uri(configuration["IPAddress"]); diff --git a/LawFim/LawFirmExecutorApp/Controllers/CaseController.cs b/LawFim/LawFirmExecutorApp/Controllers/CaseController.cs index 9c89475..3e8df5a 100644 --- a/LawFim/LawFirmExecutorApp/Controllers/CaseController.cs +++ b/LawFim/LawFirmExecutorApp/Controllers/CaseController.cs @@ -1,12 +1,106 @@ -using Microsoft.AspNetCore.Mvc; +using LawFimDataModels.Enums; +using LawFirmContracts.BindingModels; +using LawFirmContracts.SearchModels; +using LawFirmContracts.ViewModels; +using Microsoft.AspNetCore.Mvc; namespace LawFirmExecutorApp.Controllers { - public class CaseController : Controller - { - public IActionResult Index() - { - return View(); - } - } + public class CaseController : Controller + { + [HttpGet] + public IActionResult AddClient() + { + if (APIClient.User == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + //ViewBag.Cases = APIClient.GetRequest>($"api/case/getcaselist?companyId={APIClient.User.CompanyId}"); + //ViewBag.Clients = APIClient.GetRequest>($"api/client/getclientlist?companyId={APIClient.User.CompanyId}"); + return View(); + } + [HttpPost] + public void AddClient(int id, int clientId) + { + if (APIClient.User == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + + APIClient.PostRequest("api/case/addclienttocase", Tuple.Create(new CaseSearchModel { Id = id }, new ClientViewModel { Id = clientId })); + Response.Redirect("/Home/Cases"); + } + [HttpGet] + public IActionResult CreateCase() + { + return View(); + } + [HttpPost] + public void CreateCase(string name) + { + if (APIClient.User == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + + APIClient.PostRequest("api/case/createcase", new + CaseBindingModel + { + Name = name, + DateCreate = DateTime.Now, + }); + Response.Redirect("/Home/Cases"); + } + + [HttpPost] + public void DeleteCase(int id) + { + if (APIClient.User == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + + APIClient.PostRequest("api/case/deletecase", new + CaseSearchModel + { + Name = "name", + Id = id + }); + Response.Redirect("/Home/Cases"); + } + [HttpGet] + public IActionResult UpdateCase() + { + return View(); + } + [HttpPost] + public void UpdateCase(int id, string name, int statusId) + { + if (APIClient.User == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + + APIClient.PostRequest("api/case/updatecase", new + CaseBindingModel + { + Id = id, + Name = name, + Status = (CaseStatus)statusId + }); + Response.Redirect("/Home/Cases"); + } + [HttpGet] + public IActionResult CaseClients(int id) + { + if (APIClient.User == null) + { + return Redirect("/Home/EnterLawyer"); + } + return + View(APIClient.GetRequest>($"api/case/getclientlisttocase?caseId={id}")); + } + + } + } diff --git a/LawFim/LawFirmExecutorApp/Controllers/ClientController.cs b/LawFim/LawFirmExecutorApp/Controllers/ClientController.cs index beb7d40..125b0ca 100644 --- a/LawFim/LawFirmExecutorApp/Controllers/ClientController.cs +++ b/LawFim/LawFirmExecutorApp/Controllers/ClientController.cs @@ -1,12 +1,74 @@ -using Microsoft.AspNetCore.Mvc; +using LawFirmContracts.BindingModels; +using LawFirmContracts.SearchModels; +using Microsoft.AspNetCore.Mvc; namespace LawFirmExecutorApp.Controllers { - public class ClientController : Controller - { - public IActionResult Index() - { - return View(); - } - } + public class ClientController : Controller + { + [HttpGet] + public IActionResult CreateClient() + { + return View(); + } + [HttpPost] + public void CreateClient(string fio, string phone, string email) + { + if (APIClient.User == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + + APIClient.PostRequest("api/client/createclient", new + ClientBindingModel + { + FIO = fio, + Phone = phone, + Email = email + }); + Response.Redirect("~/Client/Clients"); + } + + [HttpPost] + public void DeleteClient(int id) + { + if (APIClient.User == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + + APIClient.PostRequest("api/client/deleteclient", new + ClientSearchModel + { + Email = "g", + Phone = "g", + FIO = "g", + Id = id + }); + Response.Redirect("/Home/Clients"); + } + [HttpGet] + public IActionResult UpdateClient() + { + return View(); + } + [HttpPost] + public void UpdateClient(int id, string fio, string email, string phone) + { + if (APIClient.User == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + + APIClient.PostRequest("api/client/updateclient", new + ClientBindingModel + { + Id = id, + FIO = fio, + Email = email, + Phone = phone + }); + Response.Redirect("/Home/Clients"); + } + } } diff --git a/LawFim/LawFirmExecutorApp/Controllers/HomeController.cs b/LawFim/LawFirmExecutorApp/Controllers/HomeController.cs index e73d6ba..d8fc385 100644 --- a/LawFim/LawFirmExecutorApp/Controllers/HomeController.cs +++ b/LawFim/LawFirmExecutorApp/Controllers/HomeController.cs @@ -1,32 +1,163 @@ -using LawFirmExecutorApp.Models; +using LawFirmContracts.BindingModels; +using LawFirmContracts.ViewModels; +using LawFirmExecutorApp.Models; using Microsoft.AspNetCore.Mvc; using System.Diagnostics; namespace LawFirmExecutorApp.Controllers { - public class HomeController : Controller - { - private readonly ILogger _logger; + public class HomeController : Controller + { + private readonly ILogger _logger; - public HomeController(ILogger logger) - { - _logger = logger; - } + public HomeController(ILogger logger) + { + _logger = logger; + } - public IActionResult Index() - { - return View(); - } + // СТРАНИЦА ДЕЛ + public IActionResult Cases() + { + if (APIClient.User == null) + { + return Redirect("~/Home/Enter"); + } + return + View(APIClient.GetRequest>($"api/case/getcaselist?executorid={APIClient.User.Id}")); + } - public IActionResult Privacy() - { - return View(); - } + // СТРАНИЦА КЛИЕНТОВ + public IActionResult Clients() + { - [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] - public IActionResult Error() - { - return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); - } - } + if (APIClient.User == null) + { + return Redirect("~/Home/Enter"); + } + return + View(APIClient.GetRequest>($"api/client/getclientlist?executorid={APIClient.User}")); + } + // СТРАНИЦА ВИЗИТОВ + public IActionResult Visits() + { + + if (APIClient.User == null) + { + return Redirect("~/Home/Enter"); + } + return + View(APIClient.GetRequest>($"api/visit/getvisitlist?executorid={APIClient.User}")); + } + // Отчёт pdf исполнителя + public IActionResult CreateReportClients() + { + + if (APIClient.User == null) + { + return Redirect("~/Home/Enter"); + } + return View(); + } + [HttpGet] + public IActionResult Privacy() + { + if (APIClient.User == null) + { + return Redirect("~/Home/Enter"); + } + //ViewBag.Companies = APIClient.GetRequest>($"api/company/getcompanylist"); + return View(APIClient.User); + } + [HttpPost] + public void Privacy(string login, string password, string fio) + { + if (APIClient.User == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + if (string.IsNullOrEmpty(login) || + string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio)) + { + throw new Exception("Введите логин, пароль и ФИО"); + } + APIClient.PostRequest("api/user/updatedata", new + ExecutorBindingModel + { + Id = APIClient.User.Id, + FIO = fio, + Email = login, + Password = password + + }); + APIClient.User.FIO = fio; + APIClient.User.Email = login; + APIClient.User.Password = password; + Response.Redirect("Cases"); + } + + // РЕГИСТРАЦИЯ ИСПОЛНИТЕЛЯ + + [HttpGet] + public IActionResult Register() + { + //ViewBag.Companies = APIClient.GetRequest>($"api/company/getcompanylist"); + return View(); + } + [HttpPost] + public void Register(string login, string password, string fio) + { + if (string.IsNullOrEmpty(login) || + string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio)) + { + throw new Exception("Введите логин, пароль и ФИО"); + } + + APIClient.PostRequest("api/user/register", new + ExecutorBindingModel + { + FIO = fio, + Email = login, + Password = password + + }); + Response.Redirect("Enter"); + return; + } + + // ВХОД ДЛЯ ИСПОЛНИТЕЛЯ + + [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.User = APIClient.GetRequest($"api/user/login?login={login}&password={password}"); + if (APIClient.User == null) + { + + Response.Redirect("Enter"); + + } + else + { + /*if (APIClient.User.RoleId == 1) { Response.Redirect("/Home/Cases"); } + else */ + throw new Exception(); + } + } + + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + public IActionResult Error() + { + return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); + } + } } \ No newline at end of file diff --git a/LawFim/LawFirmExecutorApp/Controllers/ReportController.cs b/LawFim/LawFirmExecutorApp/Controllers/ReportController.cs new file mode 100644 index 0000000..1a7c703 --- /dev/null +++ b/LawFim/LawFirmExecutorApp/Controllers/ReportController.cs @@ -0,0 +1,130 @@ +using LawFirmContracts.BindingModels.Mails; +using LawFirmContracts.BindingModels; +using LawFirmContracts.ViewModels; +using Microsoft.AspNetCore.Mvc; + +namespace LawFirmExecutorApp.Controllers +{ + public class ReportController : Controller + { + + /*[HttpGet] + public void CreateReportClients(DateTime dateFrom, DateTime dateTo) + { + if (APIClient.User == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + + APIClient.GetRequest>($"api/report/getclientsreport", new ReportBindingModel + { + DateFrom = dateFrom, + DateTo = dateTo + + + + Response.Redirect("CreateReportClients"); + }*/ + [HttpPost] + + public void LoadReportClients(DateTime dateFrom, DateTime dateTo) + { + if (APIClient.User == null) + { + Redirect("~/Home/Enter"); + } + + APIClient.PostRequest($"api/report/saveclientspdffile", new ReportBindingModel + { + DateFrom = dateFrom, + DateTo = dateTo, + CompanyId = APIClient.User.CompanyId + }); + } + [HttpPost] + + public void LoadReportClientsHearingWord(int clientId) + { + if (APIClient.User == null) + { + Redirect("~/Home/Enter"); + } + + APIClient.PostRequest($"api/report/saveclientswordfile", new ReportBindingModel + { + + CompanyId = APIClient.User.CompanyId, + ClientId = clientId + }); + } + [HttpGet] + + public IActionResult GetReportClientsHearing(int clientId) + { + ViewBag.Clients = APIClient.GetRequest>($"api/client/getclientlist?companyId={APIClient.User.CompanyId}"); + if (APIClient.User == null) + { + return Redirect("~/Home/Enter"); + } + + return View(APIClient.GetRequest>($"api/report/getclientsreporthearing?clientid={clientId}&companyId={APIClient.User.CompanyId}")); + } + [HttpGet] + + public IActionResult LoadReportClients(DateTime dateFrom, DateTime dateTo, string a) + { + if (APIClient.User == null) + { + return Redirect("~/Home/Enter"); + } + + return View(APIClient.GetRequest>($"api/report/getclientsreport?datefrom={dateFrom}&dateTo={dateTo}&companyId={APIClient.User.CompanyId}")); + } + + [HttpGet] + + public IActionResult CreateReportClients(DateTime dateFrom, DateTime dateTo) + { + if (APIClient.User == null) + { + return Redirect("~/Home/Enter"); + } + + return View(APIClient.GetRequest>($"api/report/getclientsreport?datefrom={dateFrom}&dateTo={dateTo}&companyId={APIClient.User.CompanyId}")); + } + + [HttpPost] + public void LoadReportClientsHearingExcel(int clientId) + { + if (APIClient.User == null) + { + Redirect("~/Home/Enter"); + } + + APIClient.PostRequest($"api/report/saveclientsexcelfile", new ReportBindingModel + { + + CompanyId = APIClient.User.CompanyId, + ClientId = clientId + }); + } + [HttpPost] + public void SendClientsPdf(DateTime dateFrom, DateTime dateTo, string organiserEmail) + { + APIClient.PostRequest($"api/report/saveclientspdffile", new ReportBindingModel + { + DateFrom = dateFrom, + DateTo = dateTo, + CompanyId = APIClient.User.CompanyId + }); + APIClient.PostRequest("api/report/mailsend", new MailSendInfoBindingModel + { + MailAddress = "dimazhelovanov@gmail.com", + Subject = "Отчет по клиентам", + Text = "Отчет по клиентам с " + dateFrom.ToShortDateString() + " до " + dateTo.ToShortDateString() + }); + + } + + } +} diff --git a/LawFim/LawFirmExecutorApp/Controllers/VizitController.cs b/LawFim/LawFirmExecutorApp/Controllers/VizitController.cs index 6392640..b80b993 100644 --- a/LawFim/LawFirmExecutorApp/Controllers/VizitController.cs +++ b/LawFim/LawFirmExecutorApp/Controllers/VizitController.cs @@ -1,12 +1,107 @@ -using Microsoft.AspNetCore.Mvc; +using LawFirmContracts.BindingModels; +using LawFirmContracts.SearchModels; +using LawFirmContracts.ViewModels; +using Microsoft.AspNetCore.Mvc; namespace LawFirmExecutorApp.Controllers { - public class VizitController : Controller - { - public IActionResult Index() - { - return View(); - } - } + public class VisitController : Controller + { + + [HttpGet] + public IActionResult AddClient() + { + if (APIClient.User == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + //ViewBag.Visits = APIClient.GetRequest>($"api/visit/getvisitlist?companyId={APIClient.User.CompanyId}"); + //ViewBag.Clients = APIClient.GetRequest>($"api/client/getclientlist?companyId={APIClient.User.CompanyId}"); + return View(); + } + [HttpPost] + public void AddClient(int visitId, int clientId) + { + if (APIClient.User == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + + APIClient.PostRequest("api/visit/addclienttovisit", Tuple.Create(new VisitSearchModel { Id = visitId }, clientId)); + Response.Redirect("/Home/Visits"); + } + [HttpGet] + public IActionResult CreateVisit() + { + //ViewBag.Consultations = APIClient.GetRequest>($"api/consultation/getconsultationlist?companyId={APIClient.User.CompanyId}"); + return View(); + } + [HttpPost] + public void CreateVisit(DateTime visitDate, int hearingId) + { + if (APIClient.User == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + + //ViewBag.Consultations = APIClient.GetRequest>($"api/consultation/getconsultationlist?companyId={APIClient.User.CompanyId}"); + + APIClient.PostRequest("api/visit/createvisit", new + VisitBindingModel + { + VisitDate = visitDate, + HearingId = hearingId + }); + Response.Redirect("/Home/Visits"); + } + + [HttpPost] + public void DeleteVisit(int id) + { + if (APIClient.User == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + + APIClient.PostRequest("api/visit/deletevisit", new + VisitSearchModel + { + Id = id + }); + Response.Redirect("/Home/Visits"); + } + [HttpGet] + public IActionResult UpdateVisit() + { + return View(); + } + [HttpPost] + public void UpdateVisit(int id, DateTime visitDate, int hearingId) + { + if (APIClient.User == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + + APIClient.PostRequest("api/visit/updatevisit", new + VisitBindingModel + { + Id = id, + VisitDate = visitDate, + HearingId = hearingId + + }); + Response.Redirect("/Home/Visits"); + } + [HttpGet] + public IActionResult VisitClients(int id) + { + if (APIClient.User == null) + { + return Redirect("~/Home/EnterLawyer"); + } + return + View(APIClient.GetRequest>($"api/visit/getclientlisttovisit?visitId={id}")); + } + } }