добавила dateto datefrom для слушаний и консультаций, в приложение всякого надобавляла

This commit is contained in:
a.puchkina 2024-04-30 00:27:07 +04:00
parent 5997176256
commit dfb80676c7
22 changed files with 361 additions and 39 deletions

View File

@ -5,6 +5,8 @@
public int? Id { get; set; } public int? Id { get; set; }
public double? Cost { get; set; } public double? Cost { get; set; }
public DateTime? ConsultationDate { get; set; } public DateTime? ConsultationDate { get; set; }
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
public int? CaseId { get; set; } public int? CaseId { get; set; }
public int? GuarantorId { get; set; } public int? GuarantorId { get; set; }
} }

View File

@ -4,6 +4,8 @@
{ {
public int? Id { get; set; } public int? Id { get; set; }
public DateTime? HearingDate { get; set; } public DateTime? HearingDate { get; set; }
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
public int? GuarantorId { get; set; } public int? GuarantorId { get; set; }
} }
} }

View File

@ -14,8 +14,6 @@ namespace LawFirmContracts.ViewModels
[DisplayName("Дело")] [DisplayName("Дело")]
public string CaseName { get; set; } = string.Empty; public string CaseName { get; set; } = string.Empty;
public int CaseId { get; set; } public int CaseId { get; set; }
[DisplayName("Имя поручителя")]
public string GuarantorName { get; set; } = string.Empty;
public int GuarantorId { get; set; } public int GuarantorId { get; set; }
public Dictionary<int, ILawyerModel> ConsultationLawyers { get; set; } = new(); public Dictionary<int, ILawyerModel> ConsultationLawyers { get; set; } = new();
} }

View File

@ -11,8 +11,6 @@ namespace LawFirmContracts.ViewModels
public DateTime HearingDate { get; set; } public DateTime HearingDate { get; set; }
[DisplayName("Суд")] [DisplayName("Суд")]
public string Judge { get; set; } = string.Empty; public string Judge { get; set; } = string.Empty;
[DisplayName("Имя поручителя")]
public string GuarantorName { get; set; } = string.Empty;
public int GuarantorId { get; set; } public int GuarantorId { get; set; }
public Dictionary<int, ILawyerModel> HearingLawyers { get; set; } = new(); public Dictionary<int, ILawyerModel> HearingLawyers { get; set; } = new();
} }

View File

@ -21,10 +21,23 @@ namespace LawFirmDatabaseImplement.Implements
} }
public List<ConsultationViewModel> GetFilteredList(ConsultationSearchModel model) public List<ConsultationViewModel> 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(); return new();
} }
if (!model.GuarantorId.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
{
using var context = new LawFirmDatabase();
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) if (!model.GuarantorId.HasValue)
{ {
using var context = new LawFirmDatabase(); using var context = new LawFirmDatabase();
@ -32,6 +45,18 @@ namespace LawFirmDatabaseImplement.Implements
.Include(x => x.Lawyers) .Include(x => x.Lawyers)
.ThenInclude(x => x.Lawyer) .ThenInclude(x => x.Lawyer)
.Where(x => x.GuarantorId == model.GuarantorId) .Where(x => x.GuarantorId == model.GuarantorId)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
else if (!model.DateFrom.HasValue || !model.DateTo.HasValue)
{
using var context = new LawFirmDatabase();
return context.Consultations
.Include(x => x.Lawyers)
.ThenInclude(x => x.Lawyer)
.Where(x => x.Id == model.Id)
.ToList()
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
} }
@ -41,14 +66,15 @@ namespace LawFirmDatabaseImplement.Implements
return context.Consultations return context.Consultations
.Include(x => x.Lawyers) .Include(x => x.Lawyers)
.ThenInclude(x => x.Lawyer) .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) .Select(x => x.GetViewModel)
.ToList(); .ToList();
} }
} }
public ConsultationViewModel? GetElement(ConsultationSearchModel model) public ConsultationViewModel? GetElement(ConsultationSearchModel model)
{ {
if (!model.Id.HasValue && !model.GuarantorId.HasValue) if (!model.Id.HasValue && !model.GuarantorId.HasValue && !model.ConsultationDate.HasValue)
{ {
return null; return null;
} }

View File

@ -21,11 +21,22 @@ namespace LawFirmDatabaseImplement.Implements
} }
public List<HearingViewModel> GetFilteredList(HearingSearchModel model) public List<HearingViewModel> 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(); return new();
} }
if (!model.GuarantorId.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
{
using var context = new LawFirmDatabase();
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) if (!model.GuarantorId.HasValue)
{ {
using var context = new LawFirmDatabase(); using var context = new LawFirmDatabase();
@ -36,7 +47,7 @@ namespace LawFirmDatabaseImplement.Implements
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
} }
else else if (!model.DateFrom.HasValue || !model.DateTo.HasValue)
{ {
using var context = new LawFirmDatabase(); using var context = new LawFirmDatabase();
return context.Hearings return context.Hearings
@ -46,10 +57,20 @@ namespace LawFirmDatabaseImplement.Implements
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
} }
else
{
using var context = new LawFirmDatabase();
return context.Hearings
.Include(x => x.Lawyers)
.ThenInclude(x => x.Lawyer)
.Where(x => x.HearingDate >= model.DateFrom && x.HearingDate <= model.DateTo)
.Select(x => x.GetViewModel)
.ToList();
}
} }
public HearingViewModel? GetElement(HearingSearchModel model) public HearingViewModel? GetElement(HearingSearchModel model)
{ {
if (!model.Id.HasValue && !model.GuarantorId.HasValue) if (!model.Id.HasValue && !model.GuarantorId.HasValue && !model.HearingDate.HasValue)
{ {
return null; return null;
} }

View File

@ -11,9 +11,9 @@ namespace LawFirmDatabaseImplement
{ {
if (optionsBuilder.IsConfigured == false) if (optionsBuilder.IsConfigured == false)
{ {
optionsBuilder.UseSqlServer(@"Data Source=ZIRAEL\SQLEXPRESS;Initial Catalog=LawFirmDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); //optionsBuilder.UseSqlServer(@"Data Source=ZIRAEL\SQLEXPRESS;Initial Catalog=LawFirmDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
//optionsBuilder.UseSqlServer(@"Data Source=PC-Anna\SQLEXPRESS;Initial Catalog=LawFirmDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); optionsBuilder.UseSqlServer(@"Data Source=PC-Anna\SQLEXPRESS;Initial Catalog=LawFirmDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
} }
base.OnConfiguring(optionsBuilder); base.OnConfiguring(optionsBuilder);
} }

View File

@ -4,6 +4,7 @@ var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllersWithViews(); builder.Services.AddControllersWithViews();
var app = builder.Build(); var app = builder.Build();
APIClient.Connect(builder.Configuration);
// Configure the HTTP request pipeline. // Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment()) if (!app.Environment.IsDevelopment())
@ -22,6 +23,6 @@ app.UseAuthorization();
app.MapControllerRoute( app.MapControllerRoute(
name: "default", name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}"); pattern: "{controller=Home}/{action=EnterGuarantor}/{id?}");
app.Run(); app.Run();

View File

@ -0,0 +1,61 @@
@{
ViewData["Title"] = "Create Consultation";
Layout = "~/Views/Shared/_LayoutGuarantor.cshtml";
}
<div class="text-center">
<h1 class="display-4">Список консультаций</h1>
</div>
<div class="text-center">
@{
<p>
<a asp-controller="Consultation" asp-action="CreateConsultation">Назначить консультацию</a>
<a asp-controller="Consultation" asp-action="AddLawyer">Добавить юристов к консультациям</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Номер
</th>
<th>
Стоимость консультации
</th>
<th>
Дата консультации
</th>
<th>
Наименование дела
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td id="id">
@Html.DisplayFor(modelItem =>
item.Id)
</td>
<td>
@Html.DisplayFor(modelItem =>
item.Cost)
</td>
<td>
@Html.DisplayFor(modelItem =>
item.CaseName)
</td>
<td>
<button type="submit" class="btn btn-danger">Удалить</button>
</td>
<td>
<button type="submit" class="btn btn-danger">Изменить</button>
</td>
<td>
<button type="submit" class="btn btn-danger">Юристы</button>
</td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -0,0 +1,21 @@
@{
ViewData["Title"] = "Enter";
Layout = "~/Views/Shared/_LayoutGuarantor.cshtml";
}
<div class="text-center">
<h2 class="display-4">Вход в приложение</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Электронная почта:</div>
<div class="col-8"><input type="text" name="email" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="password" name="password" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Вход" class="btn btnprimary" /></div>
</div>
</form>

View File

@ -0,0 +1,58 @@
@{
ViewData["Title"] = "Create Hearing";
Layout = "~/Views/Shared/_LayoutGuarantor.cshtml";
}
<div class="text-center">
<h1 class="display-4">Список слушаний</h1>
</div>
<div class="text-center">
@{
<p>
<a asp-controller="Hearing" asp-action="CreateHearing">Назначить слушание</a>
<a asp-controller="Hearing" asp-action="AddLawyer">Добавить юристов к слушаниям</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Номер
</th>
<th>
Дата слушания
</th>
<th>
Наименование суда
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td id="id">
@Html.DisplayFor(modelItem =>
item.Id)
</td>
<td>
@Html.DisplayFor(modelItem =>
item.HearingDate)
</td>
<td>
@Html.DisplayFor(modelItem =>
item.Judge)
</td>
<td>
<button type="submit" class="btn btn-danger">Удалить</button>
</td>
<td>
<button type="submit" class="btn btn-danger">Изменить</button>
</td>
<td>
<button type="submit" class="btn btn-danger">Юристы</button>
</td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -1,8 +0,0 @@
@{
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
</div>

View File

@ -0,0 +1,67 @@
@{
ViewData["Title"] = "Юристы";
Layout = "~/Views/Shared/_LayoutGuarantor.cshtml";
}
<div class="text-center">
<h1 class="display-4">Список юристов</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<p>
<a asp-controller="Lawyer" asp-action="CreateLawyer">Добавить юриста</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Номер сотрудника
</th>
<th>
ФИО
</th>
<th>
Телефон
</th>
<th>
Email
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td id="id">
@Html.DisplayFor(modelItem =>
item.Id)
</td>
<td>
@Html.DisplayFor(modelItem =>
item.FIO)
</td>
<td>
@Html.DisplayFor(modelItem =>
item.Phone)
</td>
<td>
@Html.DisplayFor(modelItem =>
item.Email)
</td>
<td>
<button type="submit" class="btn btn-danger">Удалить</button>
</td>
<td>
<button type="submit" class="btn btn-danger">Изменить</button>
</td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -1,6 +0,0 @@
@{
ViewData["Title"] = "Privacy Policy";
}
<h1>@ViewData["Title"]</h1>
<p>Use this page to detail your site's privacy policy.</p>

View File

@ -0,0 +1,36 @@
@{
ViewData["Title"] = "Privacy Policy";
Layout = "~/Views/Shared/_LayoutGuarantor.cshtml";
}
<div class="text-center">
<h2 class="display-4">Личные данные</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Электронная почта:</div>
<div class="col-8">
<input type="text" name="email"
value="@Model.Email" />
</div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8">
<input type="password" name="password"
value="@Model.Password" />
</div>
</div>
<div class="row">
<div class="col-4">ФИО:</div>
<div class="col-8">
<input type="text" name="fio"
value="@Model.FIO" />
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4">
<input type="submit" value="Сохранить" class="btn btn-primary" />
</div>
</div>
</form>

View File

@ -0,0 +1,28 @@
@{
ViewData["Title"] = "Register";
Layout = "~/Views/Shared/_LayoutGuarantor.cshtml";
}
<div class="text-center">
<h2 class="display-4">Регистрация поручителя</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Электронная почта:</div>
<div class="col-8"><input type="text" name="email" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="password" name="password" /></div>
</div>
<div class="row">
<div class="col-4">ФИО:</div>
<div class="col-8"><input type="text" name="fio" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4">
<input type="submit" value="Регистрация"
class="btn btn-primary" />
</div>
</div>
</form>

View File

@ -12,7 +12,7 @@
<header> <header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3"> <nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container-fluid"> <div class="container-fluid">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">LawFirmGuarantorApp</a> <a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Lawyers">LawFirmGuarantorApp</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent" <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation"> aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
@ -20,10 +20,25 @@
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between"> <div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1"> <ul class="navbar-nav flex-grow-1">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Lawyers">Home</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a> <a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Lawyers">Юристы</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Hearings">Слушания</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Consultations">Консультации</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="PrivacyGuarantor">Личные данные</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="RegisterGuarantor">Регистрация</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="EnterGuarantor">Вход</a>
</li> </li>
</ul> </ul>
</div> </div>
@ -38,7 +53,7 @@
<footer class="border-top footer text-muted"> <footer class="border-top footer text-muted">
<div class="container"> <div class="container">
&copy; 2024 - LawFirmGuarantorApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a> &copy; 2024 - LawFirmGuarantorApp - <a asp-area="" asp-controller="Home" asp-action="PrivacyGuarantor">Privacy</a>
</div> </div>
</footer> </footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script> <script src="~/lib/jquery/dist/jquery.min.js"></script>

View File

@ -1,3 +1,3 @@
@{ @{
Layout = "_Layout"; Layout = "_LayoutGuarantor";
} }

View File

@ -5,5 +5,7 @@
"Microsoft.AspNetCore": "Warning" "Microsoft.AspNetCore": "Warning"
} }
}, },
"AllowedHosts": "*" "AllowedHosts": "*",
"IPAddress": "http://localhost:5256/"
} }