работа над приложением, датами слушаний и консультаций

This commit is contained in:
sofiaivv 2024-05-03 01:37:16 +04:00
parent ea7cf43cf9
commit ed15c81c92
22 changed files with 104 additions and 35 deletions

View File

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

View File

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

View File

@ -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<int, ILawyerModel> ConsultationLawyers { get; set; } = new();
}

View File

@ -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<int, ILawyerModel> HearingLawyers { get; set; } = new();
}

View File

@ -21,10 +21,23 @@ namespace LawCompanyDatabaseImplement.Implements
}
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();
}
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;
}

View File

@ -21,11 +21,22 @@ namespace LawCompanyDatabaseImplement.Implements
}
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();
}
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)
{

View File

@ -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);
}

View File

@ -0,0 +1,6 @@
namespace LawCompanyGuarantorApp
{
public class APIClient
{
}
}

View File

@ -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();

View File

@ -0,0 +1,5 @@
@*
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
}

View File

@ -0,0 +1,5 @@
@*
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
}

View File

@ -0,0 +1,5 @@
@*
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
}

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,5 @@
@*
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
}

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,5 @@
@*
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
}

View File

@ -0,0 +1,5 @@
@*
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
}

View File

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