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"; }