From ed15c81c92104096c5e4c9998d08efe006b96a80 Mon Sep 17 00:00:00 2001 From: sofiaivv Date: Fri, 3 May 2024 01:37:16 +0400 Subject: [PATCH] =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20=D0=BD?= =?UTF-8?q?=D0=B0=D0=B4=20=D0=BF=D1=80=D0=B8=D0=BB=D0=BE=D0=B6=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=D0=BC,=20=D0=B4=D0=B0=D1=82=D0=B0=D0=BC=D0=B8=20?= =?UTF-8?q?=D1=81=D0=BB=D1=83=D1=88=D0=B0=D0=BD=D0=B8=D0=B9=20=D0=B8=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=81=D1=83=D0=BB=D1=8C=D1=82=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SearchModels/ConsultationSearchModel.cs | 6 ++-- .../SearchModels/HearingSearchModel.cs | 6 ++-- .../ViewModels/ConsultationViewModel.cs | 2 -- ...ntorViewModel.cs => GuarantorViewModel.cs} | 0 ...earingViewModel.cs => HearingViewModel.cs} | 2 -- ...ILawyerViewModel.cs => LawyerViewModel.cs} | 0 .../Implements/ConsultationStorage.cs | 32 +++++++++++++++-- .../Implements/HearingStorage.cs | 34 +++++++++++++++---- .../LawCompanyDatabase.cs | 2 +- .../LawCompanyGuarantorApp/APIClient.cs | 6 ++++ LawCompany/LawCompanyGuarantorApp/Program.cs | 3 +- .../Views/Home/Consultation.cshtml | 5 +++ .../Views/Home/EnterGuarantor.cshtml | 5 +++ .../Views/Home/Hearings.cshtml | 5 +++ .../Views/Home/Index.cshtml | 8 ----- .../Views/Home/Lawyers.cshtml | 5 +++ .../Views/Home/Privacy.cshtml | 6 ---- .../Views/Home/PrivacyGuarantor.cshtml | 5 +++ .../Views/Home/RegisterGuarantor.cshtml | 5 +++ ..._Layout.cshtml => _LayoutGuarantor.cshtml} | 0 ...cshtml.css => _LayoutGuarantor.cshtml.css} | 0 .../Views/_ViewStart.cshtml | 2 +- 22 files changed, 104 insertions(+), 35 deletions(-) rename LawCompany/LawCompanyContracts/ViewModels/{IGuarantorViewModel.cs => GuarantorViewModel.cs} (100%) rename LawCompany/LawCompanyContracts/ViewModels/{IHearingViewModel.cs => HearingViewModel.cs} (83%) rename LawCompany/LawCompanyContracts/ViewModels/{ILawyerViewModel.cs => LawyerViewModel.cs} (100%) create mode 100644 LawCompany/LawCompanyGuarantorApp/APIClient.cs create mode 100644 LawCompany/LawCompanyGuarantorApp/Views/Home/Consultation.cshtml create mode 100644 LawCompany/LawCompanyGuarantorApp/Views/Home/EnterGuarantor.cshtml create mode 100644 LawCompany/LawCompanyGuarantorApp/Views/Home/Hearings.cshtml delete mode 100644 LawCompany/LawCompanyGuarantorApp/Views/Home/Index.cshtml create mode 100644 LawCompany/LawCompanyGuarantorApp/Views/Home/Lawyers.cshtml delete mode 100644 LawCompany/LawCompanyGuarantorApp/Views/Home/Privacy.cshtml create mode 100644 LawCompany/LawCompanyGuarantorApp/Views/Home/PrivacyGuarantor.cshtml create mode 100644 LawCompany/LawCompanyGuarantorApp/Views/Home/RegisterGuarantor.cshtml rename LawCompany/LawCompanyGuarantorApp/Views/Shared/{_Layout.cshtml => _LayoutGuarantor.cshtml} (100%) rename LawCompany/LawCompanyGuarantorApp/Views/Shared/{_Layout.cshtml.css => _LayoutGuarantor.cshtml.css} (100%) diff --git a/LawCompany/LawCompanyContracts/SearchModels/ConsultationSearchModel.cs b/LawCompany/LawCompanyContracts/SearchModels/ConsultationSearchModel.cs index b8c9ac2..1777a7a 100644 --- a/LawCompany/LawCompanyContracts/SearchModels/ConsultationSearchModel.cs +++ b/LawCompany/LawCompanyContracts/SearchModels/ConsultationSearchModel.cs @@ -5,7 +5,9 @@ public int? Id { get; set; } public double? Cost { get; set; } public DateTime? ConsultationDate { get; set; } - public int? CaseId { get; set; } - public int? GuarantorId { get; set; } + public DateTime? DateFrom { get; set; } + public DateTime? DateTo { get; set; } + public int? CaseId { get; set; } + public int? GuarantorId { get; set; } } } diff --git a/LawCompany/LawCompanyContracts/SearchModels/HearingSearchModel.cs b/LawCompany/LawCompanyContracts/SearchModels/HearingSearchModel.cs index 6a61846..cb68e09 100644 --- a/LawCompany/LawCompanyContracts/SearchModels/HearingSearchModel.cs +++ b/LawCompany/LawCompanyContracts/SearchModels/HearingSearchModel.cs @@ -4,6 +4,8 @@ { public int? Id { get; set; } public DateTime? HearingDate { get; set; } - public int? GuarantorId { get; set; } - } + public DateTime? DateFrom { get; set; } + public DateTime? DateTo { get; set; } + public int? GuarantorId { get; set; } + } } diff --git a/LawCompany/LawCompanyContracts/ViewModels/ConsultationViewModel.cs b/LawCompany/LawCompanyContracts/ViewModels/ConsultationViewModel.cs index 0e6b070..518d224 100644 --- a/LawCompany/LawCompanyContracts/ViewModels/ConsultationViewModel.cs +++ b/LawCompany/LawCompanyContracts/ViewModels/ConsultationViewModel.cs @@ -14,8 +14,6 @@ namespace LawCompanyContracts.ViewModels [DisplayName("Дело")] public string CaseName { get; set; } = string.Empty; public int CaseId { get; set; } - [DisplayName("Имя поручителя")] - public string GuarantorName { get; set; } = string.Empty; public int GuarantorId { get; set; } public Dictionary ConsultationLawyers { get; set; } = new(); } diff --git a/LawCompany/LawCompanyContracts/ViewModels/IGuarantorViewModel.cs b/LawCompany/LawCompanyContracts/ViewModels/GuarantorViewModel.cs similarity index 100% rename from LawCompany/LawCompanyContracts/ViewModels/IGuarantorViewModel.cs rename to LawCompany/LawCompanyContracts/ViewModels/GuarantorViewModel.cs diff --git a/LawCompany/LawCompanyContracts/ViewModels/IHearingViewModel.cs b/LawCompany/LawCompanyContracts/ViewModels/HearingViewModel.cs similarity index 83% rename from LawCompany/LawCompanyContracts/ViewModels/IHearingViewModel.cs rename to LawCompany/LawCompanyContracts/ViewModels/HearingViewModel.cs index ec409c6..684dc53 100644 --- a/LawCompany/LawCompanyContracts/ViewModels/IHearingViewModel.cs +++ b/LawCompany/LawCompanyContracts/ViewModels/HearingViewModel.cs @@ -11,8 +11,6 @@ namespace LawCompanyContracts.ViewModels public DateTime HearingDate { get; set; } [DisplayName("Суд")] public string Judge { get; set; } = string.Empty; - [DisplayName("Имя поручителя")] - public string GuarantorName { get; set; } = string.Empty; public int GuarantorId { get; set; } public Dictionary HearingLawyers { get; set; } = new(); } diff --git a/LawCompany/LawCompanyContracts/ViewModels/ILawyerViewModel.cs b/LawCompany/LawCompanyContracts/ViewModels/LawyerViewModel.cs similarity index 100% rename from LawCompany/LawCompanyContracts/ViewModels/ILawyerViewModel.cs rename to LawCompany/LawCompanyContracts/ViewModels/LawyerViewModel.cs diff --git a/LawCompany/LawCompanyDatabaseImplement/Implements/ConsultationStorage.cs b/LawCompany/LawCompanyDatabaseImplement/Implements/ConsultationStorage.cs index d9aff02..dc01699 100644 --- a/LawCompany/LawCompanyDatabaseImplement/Implements/ConsultationStorage.cs +++ b/LawCompany/LawCompanyDatabaseImplement/Implements/ConsultationStorage.cs @@ -21,10 +21,23 @@ namespace LawCompanyDatabaseImplement.Implements } public List GetFilteredList(ConsultationSearchModel model) { - if (!model.Id.HasValue && !model.GuarantorId.HasValue) + if (!model.Id.HasValue && !model.GuarantorId.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue + && !model.ConsultationDate.HasValue) { return new(); } + if (!model.GuarantorId.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue) + { + using var context = new LawCompanyDatabase(); + return context.Consultations + .Include(x => x.Lawyers) + .ThenInclude(x => x.Lawyer) + .Where(x => x.GuarantorId == model.GuarantorId && x.ConsultationDate >= model.DateFrom + && x.ConsultationDate <= model.DateTo) + .ToList() + .Select(x => x.GetViewModel) + .ToList(); + } if (!model.GuarantorId.HasValue) { using var context = new LawCompanyDatabase(); @@ -32,23 +45,36 @@ namespace LawCompanyDatabaseImplement.Implements .Include(x => x.Lawyers) .ThenInclude(x => x.Lawyer) .Where(x => x.GuarantorId == model.GuarantorId) + .ToList() .Select(x => x.GetViewModel) .ToList(); } + else if (!model.DateFrom.HasValue || !model.DateTo.HasValue) + { + using var context = new LawCompanyDatabase(); + return context.Consultations + .Include(x => x.Lawyers) + .ThenInclude(x => x.Lawyer) + .Where(x => x.Id == model.Id) + .ToList() + .Select(x => x.GetViewModel) + .ToList(); + } else { using var context = new LawCompanyDatabase(); return context.Consultations .Include(x => x.Lawyers) .ThenInclude(x => x.Lawyer) - .Where(x => x.Id == model.Id) + .Where(x => x.ConsultationDate >= model.DateFrom && x.ConsultationDate <= model.DateTo) + .ToList() .Select(x => x.GetViewModel) .ToList(); } } public ConsultationViewModel? GetElement(ConsultationSearchModel model) { - if (!model.Id.HasValue && !model.GuarantorId.HasValue) + if (!model.Id.HasValue && !model.GuarantorId.HasValue && !model.ConsultationDate.HasValue) { return null; } diff --git a/LawCompany/LawCompanyDatabaseImplement/Implements/HearingStorage.cs b/LawCompany/LawCompanyDatabaseImplement/Implements/HearingStorage.cs index a329865..8d70d34 100644 --- a/LawCompany/LawCompanyDatabaseImplement/Implements/HearingStorage.cs +++ b/LawCompany/LawCompanyDatabaseImplement/Implements/HearingStorage.cs @@ -21,11 +21,22 @@ namespace LawCompanyDatabaseImplement.Implements } public List GetFilteredList(HearingSearchModel model) { - if (!model.Id.HasValue && !model.GuarantorId.HasValue) + if (!model.Id.HasValue && !model.GuarantorId.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue + && !model.HearingDate.HasValue) { return new(); } - + if (!model.GuarantorId.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue) + { + using var context = new LawCompanyDatabase(); + return context.Hearings + .Include(x => x.Lawyers) + .ThenInclude(x => x.Lawyer) + .Where(x => x.GuarantorId == model.GuarantorId && x.HearingDate >= model.DateFrom + && x.HearingDate <= model.DateTo) + .Select(x => x.GetViewModel) + .ToList(); + } if (!model.GuarantorId.HasValue) { using var context = new LawCompanyDatabase(); @@ -36,20 +47,30 @@ namespace LawCompanyDatabaseImplement.Implements .Select(x => x.GetViewModel) .ToList(); } + else if (!model.DateFrom.HasValue || !model.DateTo.HasValue) + { + using var context = new LawCompanyDatabase(); + return context.Hearings + .Include(x => x.Lawyers) + .ThenInclude(x => x.Lawyer) + .Where(x => x.Id == model.Id) + .Select(x => x.GetViewModel) + .ToList(); + } else { using var context = new LawCompanyDatabase(); return context.Hearings .Include(x => x.Lawyers) .ThenInclude(x => x.Lawyer) - .Where(x => x.Id == model.Id) + .Where(x => x.HearingDate >= model.DateFrom && x.HearingDate <= model.DateTo) .Select(x => x.GetViewModel) .ToList(); } } public HearingViewModel? GetElement(HearingSearchModel model) { - if (!model.Id.HasValue && !model.GuarantorId.HasValue) + if (!model.Id.HasValue && !model.GuarantorId.HasValue && !model.HearingDate.HasValue) { return null; } @@ -58,9 +79,8 @@ namespace LawCompanyDatabaseImplement.Implements .Include(x => x.Lawyers) .ThenInclude(x => x.Lawyer) .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id || (model.GuarantorId.HasValue - && x.GuarantorId == model.GuarantorId)) - ?.GetViewModel; - + && x.GuarantorId == model.GuarantorId)) + ?.GetViewModel; } public HearingViewModel? Insert(HearingBindingModel model) { diff --git a/LawCompany/LawCompanyDatabaseImplement/LawCompanyDatabase.cs b/LawCompany/LawCompanyDatabaseImplement/LawCompanyDatabase.cs index a9fd10e..2bb5359 100644 --- a/LawCompany/LawCompanyDatabaseImplement/LawCompanyDatabase.cs +++ b/LawCompany/LawCompanyDatabaseImplement/LawCompanyDatabase.cs @@ -15,7 +15,7 @@ namespace LawCompanyDatabaseImplement { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseSqlServer(@"Data Source=LAPTOP-6GNIALH9\SQLEXPRESS;Initial Catalog=LawCompanyDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-H8060U3\SQLEXPRESS;Initial Catalog=LawCompanyDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); } diff --git a/LawCompany/LawCompanyGuarantorApp/APIClient.cs b/LawCompany/LawCompanyGuarantorApp/APIClient.cs new file mode 100644 index 0000000..9b17efb --- /dev/null +++ b/LawCompany/LawCompanyGuarantorApp/APIClient.cs @@ -0,0 +1,6 @@ +namespace LawCompanyGuarantorApp +{ + public class APIClient + { + } +} diff --git a/LawCompany/LawCompanyGuarantorApp/Program.cs b/LawCompany/LawCompanyGuarantorApp/Program.cs index 0727468..d1632a1 100644 --- a/LawCompany/LawCompanyGuarantorApp/Program.cs +++ b/LawCompany/LawCompanyGuarantorApp/Program.cs @@ -4,6 +4,7 @@ var builder = WebApplication.CreateBuilder(args); builder.Services.AddControllersWithViews(); var app = builder.Build(); +APIClient.Connect(builder.Configuration); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) @@ -22,6 +23,6 @@ app.UseAuthorization(); app.MapControllerRoute( name: "default", - pattern: "{controller=Home}/{action=Index}/{id?}"); + pattern: "{controller=Home}/{action=EnterGuarantor}/{id?}"); app.Run(); diff --git a/LawCompany/LawCompanyGuarantorApp/Views/Home/Consultation.cshtml b/LawCompany/LawCompanyGuarantorApp/Views/Home/Consultation.cshtml new file mode 100644 index 0000000..e1dd794 --- /dev/null +++ b/LawCompany/LawCompanyGuarantorApp/Views/Home/Consultation.cshtml @@ -0,0 +1,5 @@ +@* + For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 +*@ +@{ +} diff --git a/LawCompany/LawCompanyGuarantorApp/Views/Home/EnterGuarantor.cshtml b/LawCompany/LawCompanyGuarantorApp/Views/Home/EnterGuarantor.cshtml new file mode 100644 index 0000000..e1dd794 --- /dev/null +++ b/LawCompany/LawCompanyGuarantorApp/Views/Home/EnterGuarantor.cshtml @@ -0,0 +1,5 @@ +@* + For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 +*@ +@{ +} diff --git a/LawCompany/LawCompanyGuarantorApp/Views/Home/Hearings.cshtml b/LawCompany/LawCompanyGuarantorApp/Views/Home/Hearings.cshtml new file mode 100644 index 0000000..e1dd794 --- /dev/null +++ b/LawCompany/LawCompanyGuarantorApp/Views/Home/Hearings.cshtml @@ -0,0 +1,5 @@ +@* + For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 +*@ +@{ +} diff --git a/LawCompany/LawCompanyGuarantorApp/Views/Home/Index.cshtml b/LawCompany/LawCompanyGuarantorApp/Views/Home/Index.cshtml deleted file mode 100644 index d2d19bd..0000000 --- a/LawCompany/LawCompanyGuarantorApp/Views/Home/Index.cshtml +++ /dev/null @@ -1,8 +0,0 @@ -@{ - ViewData["Title"] = "Home Page"; -} - -
-

Welcome

-

Learn about building Web apps with ASP.NET Core.

-
diff --git a/LawCompany/LawCompanyGuarantorApp/Views/Home/Lawyers.cshtml b/LawCompany/LawCompanyGuarantorApp/Views/Home/Lawyers.cshtml new file mode 100644 index 0000000..e1dd794 --- /dev/null +++ b/LawCompany/LawCompanyGuarantorApp/Views/Home/Lawyers.cshtml @@ -0,0 +1,5 @@ +@* + For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 +*@ +@{ +} diff --git a/LawCompany/LawCompanyGuarantorApp/Views/Home/Privacy.cshtml b/LawCompany/LawCompanyGuarantorApp/Views/Home/Privacy.cshtml deleted file mode 100644 index af4fb19..0000000 --- a/LawCompany/LawCompanyGuarantorApp/Views/Home/Privacy.cshtml +++ /dev/null @@ -1,6 +0,0 @@ -@{ - ViewData["Title"] = "Privacy Policy"; -} -

@ViewData["Title"]

- -

Use this page to detail your site's privacy policy.

diff --git a/LawCompany/LawCompanyGuarantorApp/Views/Home/PrivacyGuarantor.cshtml b/LawCompany/LawCompanyGuarantorApp/Views/Home/PrivacyGuarantor.cshtml new file mode 100644 index 0000000..e1dd794 --- /dev/null +++ b/LawCompany/LawCompanyGuarantorApp/Views/Home/PrivacyGuarantor.cshtml @@ -0,0 +1,5 @@ +@* + For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 +*@ +@{ +} diff --git a/LawCompany/LawCompanyGuarantorApp/Views/Home/RegisterGuarantor.cshtml b/LawCompany/LawCompanyGuarantorApp/Views/Home/RegisterGuarantor.cshtml new file mode 100644 index 0000000..e1dd794 --- /dev/null +++ b/LawCompany/LawCompanyGuarantorApp/Views/Home/RegisterGuarantor.cshtml @@ -0,0 +1,5 @@ +@* + For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 +*@ +@{ +} diff --git a/LawCompany/LawCompanyGuarantorApp/Views/Shared/_Layout.cshtml b/LawCompany/LawCompanyGuarantorApp/Views/Shared/_LayoutGuarantor.cshtml similarity index 100% rename from LawCompany/LawCompanyGuarantorApp/Views/Shared/_Layout.cshtml rename to LawCompany/LawCompanyGuarantorApp/Views/Shared/_LayoutGuarantor.cshtml diff --git a/LawCompany/LawCompanyGuarantorApp/Views/Shared/_Layout.cshtml.css b/LawCompany/LawCompanyGuarantorApp/Views/Shared/_LayoutGuarantor.cshtml.css similarity index 100% rename from LawCompany/LawCompanyGuarantorApp/Views/Shared/_Layout.cshtml.css rename to LawCompany/LawCompanyGuarantorApp/Views/Shared/_LayoutGuarantor.cshtml.css diff --git a/LawCompany/LawCompanyGuarantorApp/Views/_ViewStart.cshtml b/LawCompany/LawCompanyGuarantorApp/Views/_ViewStart.cshtml index a5f1004..6fed748 100644 --- a/LawCompany/LawCompanyGuarantorApp/Views/_ViewStart.cshtml +++ b/LawCompany/LawCompanyGuarantorApp/Views/_ViewStart.cshtml @@ -1,3 +1,3 @@ @{ - Layout = "_Layout"; + Layout = "_LayoutGuarantor"; }