This commit is contained in:
Софья Якобчук 2024-08-28 03:31:42 +04:00
parent 448737fe3a
commit e9fa2500ee
12 changed files with 1098 additions and 1098 deletions

View File

@ -14,82 +14,82 @@ namespace LawCompanyBusinessLogic.OfficePackage
{ {
CreatePdf(info); CreatePdf(info);
CreateParagraph(new PdfParagraph CreateParagraph(new PdfParagraph
{ {
Text = info.Title, Text = info.Title,
Style = "NormalTitle", Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center ParagraphAlignment = PdfParagraphAlignmentType.Center
}); });
CreateParagraph(new PdfParagraph CreateParagraph(new PdfParagraph
{ {
Text = $"с{info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", Text = $"с{info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}",
Style = "Normal", Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Center ParagraphAlignment = PdfParagraphAlignmentType.Center
}); });
CreateTable(new List<string> { "3cm", "5cm", "5cm" }); CreateTable(new List<string> { "3cm", "5cm", "5cm" });
CreateRow(new PdfRowParameters CreateRow(new PdfRowParameters
{ {
Texts = new List<string> { "Юрист", "Цена консультации", "Дата консультации" }, Texts = new List<string> { "Юрист", "Цена консультации", "Дата консультации" },
Style = "NormalTitle", Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center ParagraphAlignment = PdfParagraphAlignmentType.Center
}); });
foreach (var ch in info.Lawyers) foreach (var ch in info.Lawyers)
{ {
CreateRow(new PdfRowParameters CreateRow(new PdfRowParameters
{ {
Texts = new List<string> { ch.FIO, " ", " " }, Texts = new List<string> { ch.FIO, " ", " " },
Style = "Normal", Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Center ParagraphAlignment = PdfParagraphAlignmentType.Center
}); });
foreach (var cons in ch.Consultation) foreach (var cons in ch.Consultation)
CreateRow(new PdfRowParameters CreateRow(new PdfRowParameters
{ {
Texts = new List<string> { " ", cons.Price.ToString() + " рублей", cons.ConsultationDate.ToShortDateString() }, Texts = new List<string> { " ", cons.Price.ToString() + " рублей", cons.ConsultationDate.ToShortDateString() },
Style = "Normal", Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Center ParagraphAlignment = PdfParagraphAlignmentType.Center
}); });
CreateRow(new PdfRowParameters CreateRow(new PdfRowParameters
{ {
Texts = new List<string> { " ", " ", "Итого: " + ch.Consultation.Count.ToString() }, Texts = new List<string> { " ", " ", "Итого: " + ch.Consultation.Count.ToString() },
Style = "Normal", Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Rigth ParagraphAlignment = PdfParagraphAlignmentType.Rigth
}); });
} }
CreateTable(new List<string> { "3cm", "5cm", "5cm" }); CreateTable(new List<string> { "3cm", "5cm", "5cm" });
CreateRow(new PdfRowParameters CreateRow(new PdfRowParameters
{ {
Texts = new List<string> { "Юрист", "Суд", "Дата слушания" }, Texts = new List<string> { "Юрист", "Суд", "Дата слушания" },
Style = "NormalTitle", Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center ParagraphAlignment = PdfParagraphAlignmentType.Center
}); });
foreach (var ch in info.Lawyers) foreach (var ch in info.Lawyers)
{ {
CreateRow(new PdfRowParameters CreateRow(new PdfRowParameters
{ {
Texts = new List<string> { ch.FIO, " ", " " }, Texts = new List<string> { ch.FIO, " ", " " },
Style = "Normal", Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Center ParagraphAlignment = PdfParagraphAlignmentType.Center
}); });
foreach (var hear in ch.Hearing) foreach (var hear in ch.Hearing)
CreateRow(new PdfRowParameters CreateRow(new PdfRowParameters
{ {
Texts = new List<string> { " ", hear.Judge, hear.HearingDate.ToShortDateString() }, Texts = new List<string> { " ", hear.Judge, hear.HearingDate.ToShortDateString() },
Style = "Normal", Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left ParagraphAlignment = PdfParagraphAlignmentType.Left
}); });
CreateRow(new PdfRowParameters CreateRow(new PdfRowParameters
{ {
Texts = new List<string> { " ", " ", "Итого: " + ch.Hearing.Count.ToString() }, Texts = new List<string> { " ", " ", "Итого: " + ch.Hearing.Count.ToString() },
Style = "Normal", Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Rigth ParagraphAlignment = PdfParagraphAlignmentType.Rigth
}); });
} }
SavePdf(info); SavePdf(info);
} }
protected abstract void CreatePdf(PdfInfoGuarantor info); protected abstract void CreatePdf(PdfInfoGuarantor info);
protected abstract void CreateParagraph(PdfParagraph paragraph); protected abstract void CreateParagraph(PdfParagraph paragraph);

View File

@ -1,6 +1,6 @@
namespace LawCompanyContracts.ViewModels namespace LawCompanyContracts.ViewModels
{ {
public class ReportLawyerHearingViewModel public class ReportLawyerHearingViewModel
{ {
public string FIO { get; set; } = string.Empty; public string FIO { get; set; } = string.Empty;
public List<Tuple<string, DateTime>> Visits { get; set; } = new(); public List<Tuple<string, DateTime>> Visits { get; set; } = new();

View File

@ -7,18 +7,18 @@ using Microsoft.EntityFrameworkCore;
namespace LawCompanyDatabaseImplement.Implements namespace LawCompanyDatabaseImplement.Implements
{ {
public class ConsultationStorage : IConsultationStorage public class ConsultationStorage : IConsultationStorage
{ {
public List<ConsultationViewModel> GetFullList() public List<ConsultationViewModel> GetFullList()
{ {
using var context = new LawCompanyDatabase(); using var context = new LawCompanyDatabase();
return context.Consultations return context.Consultations
.Include(x => x.Lawyers) .Include(x => x.Lawyers)
.ThenInclude(x => x.Lawyer) .ThenInclude(x => x.Lawyer)
.ToList() .ToList()
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
} }
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)

View File

@ -15,8 +15,8 @@ namespace LawCompanyDatabaseImplement
{ {
if (optionsBuilder.IsConfigured == false) 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=LAPTOP-6GNIALH9\SQLEXPRESS;Initial Catalog=LawCompanyDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-7DB3VEN\SQLEXPRESS;Initial Catalog=Test1;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); //optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-7DB3VEN\SQLEXPRESS;Initial Catalog=LawCompanyDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
} }
base.OnConfiguring(optionsBuilder); base.OnConfiguring(optionsBuilder);
} }

View File

@ -10,525 +10,525 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace LawCompanyDatabaseImplement.Migrations namespace LawCompanyDatabaseImplement.Migrations
{ {
[DbContext(typeof(LawCompanyDatabase))] [DbContext(typeof(LawCompanyDatabase))]
partial class LawCompanyDatabaseModelSnapshot : ModelSnapshot partial class LawCompanyDatabaseModelSnapshot : ModelSnapshot
{ {
protected override void BuildModel(ModelBuilder modelBuilder) protected override void BuildModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "7.0.17") .HasAnnotation("ProductVersion", "7.0.17")
.HasAnnotation("Relational:MaxIdentifierLength", 128); .HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Case", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Case", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime>("DateCreate") b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement") b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<int>("ExecutorId") b.Property<int>("ExecutorId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<int>("Status") b.Property<int>("Status")
.HasColumnType("int"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("ExecutorId"); b.HasIndex("ExecutorId");
b.ToTable("Cases"); b.ToTable("Cases");
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.CaseClient", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.CaseClient", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CaseId") b.Property<int>("CaseId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("ClientId") b.Property<int>("ClientId")
.HasColumnType("int"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("CaseId"); b.HasIndex("CaseId");
b.HasIndex("ClientId"); b.HasIndex("ClientId");
b.ToTable("CaseClients"); b.ToTable("CaseClients");
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Client", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Client", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Email") b.Property<string>("Email")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<int>("ExecutorId") b.Property<int>("ExecutorId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<string>("FIO") b.Property<string>("FIO")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("Phone") b.Property<string>("Phone")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("ExecutorId"); b.HasIndex("ExecutorId");
b.ToTable("Clients"); b.ToTable("Clients");
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Consultation", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Consultation", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int?>("CaseId") b.Property<int?>("CaseId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<DateTime>("ConsultationDate") b.Property<DateTime>("ConsultationDate")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<double>("Cost") b.Property<double>("Cost")
.HasColumnType("float"); .HasColumnType("float");
b.Property<int>("GuarantorId") b.Property<int>("GuarantorId")
.HasColumnType("int"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("CaseId"); b.HasIndex("CaseId");
b.HasIndex("GuarantorId"); b.HasIndex("GuarantorId");
b.ToTable("Consultations"); b.ToTable("Consultations");
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.ConsultationLawyer", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.ConsultationLawyer", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ConsultationId") b.Property<int>("ConsultationId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("LawyerId") b.Property<int>("LawyerId")
.HasColumnType("int"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("ConsultationId"); b.HasIndex("ConsultationId");
b.HasIndex("LawyerId"); b.HasIndex("LawyerId");
b.ToTable("ConsultationLawyers"); b.ToTable("ConsultationLawyers");
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Executor", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Executor", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Email") b.Property<string>("Email")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("FIO") b.Property<string>("FIO")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("Password") b.Property<string>("Password")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.HasKey("Id"); b.HasKey("Id");
b.ToTable("Executors"); b.ToTable("Executors");
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Guarantor", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Guarantor", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Email") b.Property<string>("Email")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("FIO") b.Property<string>("FIO")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("Password") b.Property<string>("Password")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.HasKey("Id"); b.HasKey("Id");
b.ToTable("Guarantors"); b.ToTable("Guarantors");
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Hearing", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Hearing", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("GuarantorId") b.Property<int>("GuarantorId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<DateTime>("HearingDate") b.Property<DateTime>("HearingDate")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<string>("Judge") b.Property<string>("Judge")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("GuarantorId"); b.HasIndex("GuarantorId");
b.ToTable("Hearings"); b.ToTable("Hearings");
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.HearingLawyer", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.HearingLawyer", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("HearingId") b.Property<int>("HearingId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("LawyerId") b.Property<int>("LawyerId")
.HasColumnType("int"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("HearingId"); b.HasIndex("HearingId");
b.HasIndex("LawyerId"); b.HasIndex("LawyerId");
b.ToTable("HearingLawyers"); b.ToTable("HearingLawyers");
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Lawyer", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Lawyer", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Email") b.Property<string>("Email")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("FIO") b.Property<string>("FIO")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<int?>("GuarantorId") b.Property<int?>("GuarantorId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<string>("Phone") b.Property<string>("Phone")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("GuarantorId"); b.HasIndex("GuarantorId");
b.ToTable("Lawyers"); b.ToTable("Lawyers");
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Visit", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Visit", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ExecutorId") b.Property<int>("ExecutorId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int?>("HearingId") b.Property<int?>("HearingId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<DateTime>("VisitDate") b.Property<DateTime>("VisitDate")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("ExecutorId"); b.HasIndex("ExecutorId");
b.HasIndex("HearingId"); b.HasIndex("HearingId");
b.ToTable("Visits"); b.ToTable("Visits");
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.VisitClient", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.VisitClient", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ClientId") b.Property<int>("ClientId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("VisitId") b.Property<int>("VisitId")
.HasColumnType("int"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("ClientId"); b.HasIndex("ClientId");
b.HasIndex("VisitId"); b.HasIndex("VisitId");
b.ToTable("VisitClients"); b.ToTable("VisitClients");
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Case", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Case", b =>
{ {
b.HasOne("LawCompanyDatabaseImplement.Models.Executor", null) b.HasOne("LawCompanyDatabaseImplement.Models.Executor", null)
.WithMany("Cases") .WithMany("Cases")
.HasForeignKey("ExecutorId") .HasForeignKey("ExecutorId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.CaseClient", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.CaseClient", b =>
{ {
b.HasOne("LawCompanyDatabaseImplement.Models.Case", "Case") b.HasOne("LawCompanyDatabaseImplement.Models.Case", "Case")
.WithMany("Clients") .WithMany("Clients")
.HasForeignKey("CaseId") .HasForeignKey("CaseId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("LawCompanyDatabaseImplement.Models.Client", "Client") b.HasOne("LawCompanyDatabaseImplement.Models.Client", "Client")
.WithMany("CaseClients") .WithMany("CaseClients")
.HasForeignKey("ClientId") .HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("Case"); b.Navigation("Case");
b.Navigation("Client"); b.Navigation("Client");
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Client", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Client", b =>
{ {
b.HasOne("LawCompanyDatabaseImplement.Models.Executor", "Executor") b.HasOne("LawCompanyDatabaseImplement.Models.Executor", "Executor")
.WithMany("Clients") .WithMany("Clients")
.HasForeignKey("ExecutorId") .HasForeignKey("ExecutorId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("Executor"); b.Navigation("Executor");
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Consultation", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Consultation", b =>
{ {
b.HasOne("LawCompanyDatabaseImplement.Models.Case", "Case") b.HasOne("LawCompanyDatabaseImplement.Models.Case", "Case")
.WithMany() .WithMany()
.HasForeignKey("CaseId"); .HasForeignKey("CaseId");
b.HasOne("LawCompanyDatabaseImplement.Models.Guarantor", null) b.HasOne("LawCompanyDatabaseImplement.Models.Guarantor", null)
.WithMany("Consultations") .WithMany("Consultations")
.HasForeignKey("GuarantorId") .HasForeignKey("GuarantorId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("Case"); b.Navigation("Case");
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.ConsultationLawyer", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.ConsultationLawyer", b =>
{ {
b.HasOne("LawCompanyDatabaseImplement.Models.Consultation", "Consultation") b.HasOne("LawCompanyDatabaseImplement.Models.Consultation", "Consultation")
.WithMany("Lawyers") .WithMany("Lawyers")
.HasForeignKey("ConsultationId") .HasForeignKey("ConsultationId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("LawCompanyDatabaseImplement.Models.Lawyer", "Lawyer") b.HasOne("LawCompanyDatabaseImplement.Models.Lawyer", "Lawyer")
.WithMany("ConsultationLawyers") .WithMany("ConsultationLawyers")
.HasForeignKey("LawyerId") .HasForeignKey("LawyerId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("Consultation"); b.Navigation("Consultation");
b.Navigation("Lawyer"); b.Navigation("Lawyer");
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Hearing", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Hearing", b =>
{ {
b.HasOne("LawCompanyDatabaseImplement.Models.Guarantor", null) b.HasOne("LawCompanyDatabaseImplement.Models.Guarantor", null)
.WithMany("Hearings") .WithMany("Hearings")
.HasForeignKey("GuarantorId") .HasForeignKey("GuarantorId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.HearingLawyer", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.HearingLawyer", b =>
{ {
b.HasOne("LawCompanyDatabaseImplement.Models.Hearing", "Hearing") b.HasOne("LawCompanyDatabaseImplement.Models.Hearing", "Hearing")
.WithMany("Lawyers") .WithMany("Lawyers")
.HasForeignKey("HearingId") .HasForeignKey("HearingId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("LawCompanyDatabaseImplement.Models.Lawyer", "Lawyer") b.HasOne("LawCompanyDatabaseImplement.Models.Lawyer", "Lawyer")
.WithMany("HearingLawyers") .WithMany("HearingLawyers")
.HasForeignKey("LawyerId") .HasForeignKey("LawyerId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("Hearing"); b.Navigation("Hearing");
b.Navigation("Lawyer"); b.Navigation("Lawyer");
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Lawyer", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Lawyer", b =>
{ {
b.HasOne("LawCompanyDatabaseImplement.Models.Guarantor", null) b.HasOne("LawCompanyDatabaseImplement.Models.Guarantor", null)
.WithMany("Lawyers") .WithMany("Lawyers")
.HasForeignKey("GuarantorId"); .HasForeignKey("GuarantorId");
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Visit", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Visit", b =>
{ {
b.HasOne("LawCompanyDatabaseImplement.Models.Executor", null) b.HasOne("LawCompanyDatabaseImplement.Models.Executor", null)
.WithMany("Visits") .WithMany("Visits")
.HasForeignKey("ExecutorId") .HasForeignKey("ExecutorId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("LawCompanyDatabaseImplement.Models.Hearing", "Hearing") b.HasOne("LawCompanyDatabaseImplement.Models.Hearing", "Hearing")
.WithMany() .WithMany()
.HasForeignKey("HearingId"); .HasForeignKey("HearingId");
b.Navigation("Hearing"); b.Navigation("Hearing");
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.VisitClient", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.VisitClient", b =>
{ {
b.HasOne("LawCompanyDatabaseImplement.Models.Client", "Client") b.HasOne("LawCompanyDatabaseImplement.Models.Client", "Client")
.WithMany("ClientVisits") .WithMany("ClientVisits")
.HasForeignKey("ClientId") .HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("LawCompanyDatabaseImplement.Models.Visit", "Visit") b.HasOne("LawCompanyDatabaseImplement.Models.Visit", "Visit")
.WithMany("Clients") .WithMany("Clients")
.HasForeignKey("VisitId") .HasForeignKey("VisitId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("Client"); b.Navigation("Client");
b.Navigation("Visit"); b.Navigation("Visit");
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Case", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Case", b =>
{ {
b.Navigation("Clients"); b.Navigation("Clients");
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Client", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Client", b =>
{ {
b.Navigation("CaseClients"); b.Navigation("CaseClients");
b.Navigation("ClientVisits"); b.Navigation("ClientVisits");
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Consultation", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Consultation", b =>
{ {
b.Navigation("Lawyers"); b.Navigation("Lawyers");
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Executor", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Executor", b =>
{ {
b.Navigation("Cases"); b.Navigation("Cases");
b.Navigation("Clients"); b.Navigation("Clients");
b.Navigation("Visits"); b.Navigation("Visits");
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Guarantor", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Guarantor", b =>
{ {
b.Navigation("Consultations"); b.Navigation("Consultations");
b.Navigation("Hearings"); b.Navigation("Hearings");
b.Navigation("Lawyers"); b.Navigation("Lawyers");
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Hearing", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Hearing", b =>
{ {
b.Navigation("Lawyers"); b.Navigation("Lawyers");
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Lawyer", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Lawyer", b =>
{ {
b.Navigation("ConsultationLawyers"); b.Navigation("ConsultationLawyers");
b.Navigation("HearingLawyers"); b.Navigation("HearingLawyers");
}); });
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Visit", b => modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Visit", b =>
{ {
b.Navigation("Clients"); b.Navigation("Clients");
}); });
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }
} }
} }

View File

@ -7,79 +7,79 @@ using System.ComponentModel.DataAnnotations;
namespace LawCompanyDatabaseImplement.Models namespace LawCompanyDatabaseImplement.Models
{ {
public class Consultation : IConsultationModel public class Consultation : IConsultationModel
{ {
public int Id { get; private set; } public int Id { get; private set; }
[Required] [Required]
public double Cost { get; private set; } public double Cost { get; private set; }
[Required] [Required]
public DateTime ConsultationDate { get; private set; } public DateTime ConsultationDate { get; private set; }
public int? CaseId { get; private set; } public int? CaseId { get; private set; }
public Case Case { get; private set; } public Case Case { get; private set; }
public int GuarantorId { get; set; } public int GuarantorId { get; set; }
private Dictionary<int, ILawyerModel> _consultationLawyers = null; private Dictionary<int, ILawyerModel> _consultationLawyers = null;
[ForeignKey("ConsultationId")] [ForeignKey("ConsultationId")]
public virtual List<ConsultationLawyer> Lawyers { get; set; } = new(); public virtual List<ConsultationLawyer> Lawyers { get; set; } = new();
[NotMapped] [NotMapped]
public Dictionary<int, ILawyerModel> ConsultationLawyers public Dictionary<int, ILawyerModel> ConsultationLawyers
{ {
get get
{ {
if (_consultationLawyers == null) if (_consultationLawyers == null)
{ {
_consultationLawyers = Lawyers.ToDictionary(x => x.LawyerId, x => (x.Lawyer as ILawyerModel)); _consultationLawyers = Lawyers.ToDictionary(x => x.LawyerId, x => (x.Lawyer as ILawyerModel));
} }
return _consultationLawyers; return _consultationLawyers;
} }
} }
public static Consultation? Create(LawCompanyDatabase context, ConsultationBindingModel? model) public static Consultation? Create(LawCompanyDatabase context, ConsultationBindingModel? model)
{ {
if (model == null) if (model == null)
{ {
return null; return null;
} }
return new Consultation() return new Consultation()
{ {
Id = model.Id, Id = model.Id,
Cost = model.Cost, Cost = model.Cost,
ConsultationDate = model.ConsultationDate, ConsultationDate = model.ConsultationDate,
CaseId = model.CaseId, CaseId = model.CaseId,
GuarantorId = model.GuarantorId, GuarantorId = model.GuarantorId,
Lawyers = model.ConsultationLawyers.Select(x => new ConsultationLawyer Lawyers = model.ConsultationLawyers.Select(x => new ConsultationLawyer
{ {
Lawyer = context.Lawyers.First(y => y.Id == x.Key) Lawyer = context.Lawyers.First(y => y.Id == x.Key)
}).ToList() }).ToList()
}; };
} }
public void Update(ConsultationBindingModel? model) public void Update(ConsultationBindingModel? model)
{ {
using var context = new LawCompanyDatabase(); using var context = new LawCompanyDatabase();
if (model == null) if (model == null)
{ {
return; return;
} }
Cost = model.Cost; Cost = model.Cost;
ConsultationDate = model.ConsultationDate; ConsultationDate = model.ConsultationDate;
CaseId = model.CaseId; CaseId = model.CaseId;
} }
public ConsultationViewModel GetViewModel => new() public ConsultationViewModel GetViewModel => new()
{ {
Id = Id, Id = Id,
Cost = Cost, Cost = Cost,
ConsultationDate = ConsultationDate, ConsultationDate = ConsultationDate,
CaseId = CaseId, CaseId = CaseId,
}; };
public void UpdateLawyers(LawCompanyDatabase context, ConsultationBindingModel model) public void UpdateLawyers(LawCompanyDatabase context, ConsultationBindingModel model)
{ {
var consultationLawyers = context.ConsultationLawyers.Where(rec => rec.ConsultationId == model.Id).ToList(); var consultationLawyers = context.ConsultationLawyers.Where(rec => rec.ConsultationId == model.Id).ToList();
if (consultationLawyers != null && consultationLawyers.Count > 0) if (consultationLawyers != null && consultationLawyers.Count > 0)
{ {
context.ConsultationLawyers.RemoveRange(consultationLawyers.Where(rec => !model.ConsultationLawyers.ContainsKey(rec.LawyerId))); context.ConsultationLawyers.RemoveRange(consultationLawyers.Where(rec => !model.ConsultationLawyers.ContainsKey(rec.LawyerId)));
context.SaveChanges(); context.SaveChanges();
foreach (var updateMember in consultationLawyers) foreach (var updateMember in consultationLawyers)
{ {
@ -87,17 +87,17 @@ namespace LawCompanyDatabaseImplement.Models
} }
context.SaveChanges(); context.SaveChanges();
} }
var _consultation = context.Consultations.First(x => x.Id == Id); var _consultation = context.Consultations.First(x => x.Id == Id);
foreach (var pc in model.ConsultationLawyers) foreach (var pc in model.ConsultationLawyers)
{ {
context.ConsultationLawyers.Add(new ConsultationLawyer context.ConsultationLawyers.Add(new ConsultationLawyer
{ {
Consultation = _consultation, Consultation = _consultation,
Lawyer = context.Lawyers.First(x => x.Id == pc.Key), Lawyer = context.Lawyers.First(x => x.Id == pc.Key),
}); });
context.SaveChanges(); context.SaveChanges();
} }
_consultationLawyers = null; _consultationLawyers = null;
} }
} }
} }

View File

@ -105,27 +105,27 @@ namespace LawCompanyGuarantorApp.Controllers
Response.Redirect("/Home/Consultations"); Response.Redirect("/Home/Consultations");
} }
[HttpGet] [HttpGet]
public IActionResult TopConsultation() public IActionResult TopConsultation()
{ {
if (APIClient.Guarantor == null) if (APIClient.Guarantor == null)
{ {
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
var consultation = APIClient.GetRequest<List<ConsultationViewModel>>($"api/consultation/GetConsultationList?guarantorId={APIClient.Guarantor.Id}"); var consultation = APIClient.GetRequest<List<ConsultationViewModel>>($"api/consultation/GetConsultationList?guarantorId={APIClient.Guarantor.Id}");
var statusCounts = consultation var statusCounts = consultation
.GroupBy(c => c.Cost) .GroupBy(c => c.Cost)
.Select(g => new .Select(g => new
{ {
Cost = g.Key.ToString(), Cost = g.Key.ToString(),
Count = g.Count() Count = g.Count()
}) })
.ToList(); .ToList();
ViewBag.StatusCounts = statusCounts; ViewBag.StatusCounts = statusCounts;
return View(); return View();
} }
} }
} }

View File

@ -7,137 +7,137 @@ using Microsoft.AspNetCore.Mvc;
namespace LawCompanyGuarantorApp.Controllers namespace LawCompanyGuarantorApp.Controllers
{ {
public class HearingController : Controller public class HearingController : Controller
{ {
[HttpGet] [HttpGet]
public IActionResult HearingLawyers(int id) public IActionResult HearingLawyers(int id)
{ {
if (APIClient.Guarantor == null) if (APIClient.Guarantor == null)
{ {
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
return View(APIClient.GetRequest<List<LawyerViewModel>>($"api/hearing/getlawyerlisttohearing?hearingId={id}")); return View(APIClient.GetRequest<List<LawyerViewModel>>($"api/hearing/getlawyerlisttohearing?hearingId={id}"));
} }
[HttpGet] [HttpGet]
public IActionResult CreateHearing() public IActionResult CreateHearing()
{ {
if (APIClient.Guarantor == null) if (APIClient.Guarantor == null)
{ {
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
ViewBag.Lawyers = APIClient.GetRequest<List<LawyerViewModel>>($"api/lawyer/GetLawyerList?guarantorId={APIClient.Guarantor.Id}"); ViewBag.Lawyers = APIClient.GetRequest<List<LawyerViewModel>>($"api/lawyer/GetLawyerList?guarantorId={APIClient.Guarantor.Id}");
return View(); return View();
} }
[HttpPost] [HttpPost]
public void CreateHearing(DateTime date, string judge, List<int> clientselect) public void CreateHearing(DateTime date, string judge, List<int> clientselect)
{ {
if (APIClient.Guarantor == null) if (APIClient.Guarantor == null)
{ {
throw new Exception("Вы как суда попали? Суда вход только авторизованным"); throw new Exception("Вы как суда попали? Суда вход только авторизованным");
} }
Dictionary<int, ILawyerModel> client = new Dictionary<int, ILawyerModel>(); Dictionary<int, ILawyerModel> client = new Dictionary<int, ILawyerModel>();
foreach (int members in clientselect) foreach (int members in clientselect)
{ {
client.Add(members, new LawyerSearchModel { Id = members } as ILawyerModel); client.Add(members, new LawyerSearchModel { Id = members } as ILawyerModel);
} }
APIClient.PostRequest("api/hearing/createhearing", new HearingBindingModel APIClient.PostRequest("api/hearing/createhearing", new HearingBindingModel
{ {
HearingDate = date, HearingDate = date,
Judge = judge, Judge = judge,
HearingLawyers = client, HearingLawyers = client,
GuarantorId = APIClient.Guarantor.Id, GuarantorId = APIClient.Guarantor.Id,
}); });
Response.Redirect("/Home/Hearings"); Response.Redirect("/Home/Hearings");
} }
[HttpGet] [HttpGet]
public IActionResult UpdateHearing() public IActionResult UpdateHearing()
{ {
if (APIClient.Guarantor == null) if (APIClient.Guarantor == null)
{ {
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
ViewBag.Lawyers = APIClient.GetRequest<List<LawyerViewModel>>($"api/lawyer/GetLawyerList?guarantorId={APIClient.Guarantor.Id}"); ViewBag.Lawyers = APIClient.GetRequest<List<LawyerViewModel>>($"api/lawyer/GetLawyerList?guarantorId={APIClient.Guarantor.Id}");
return View(); return View();
} }
[HttpPost] [HttpPost]
public void UpdateHearing(int id, DateTime date, string judge, List<int> clientselect) public void UpdateHearing(int id, DateTime date, string judge, List<int> clientselect)
{ {
if (APIClient.Guarantor == null) if (APIClient.Guarantor == null)
{ {
throw new Exception("Вы как суда попали? Суда вход только авторизованным"); throw new Exception("Вы как суда попали? Суда вход только авторизованным");
} }
Dictionary<int, ILawyerModel> client = new Dictionary<int, ILawyerModel>(); Dictionary<int, ILawyerModel> client = new Dictionary<int, ILawyerModel>();
foreach (int members in clientselect) foreach (int members in clientselect)
{ {
client.Add(members, new LawyerSearchModel { Id = members } as ILawyerModel); client.Add(members, new LawyerSearchModel { Id = members } as ILawyerModel);
} }
APIClient.PostRequest("api/hearing/updatehearing", new HearingBindingModel APIClient.PostRequest("api/hearing/updatehearing", new HearingBindingModel
{ {
Id = id, Id = id,
HearingDate = date, HearingDate = date,
Judge = judge, Judge = judge,
HearingLawyers = client, HearingLawyers = client,
GuarantorId = APIClient.Guarantor.Id, GuarantorId = APIClient.Guarantor.Id,
}); });
Response.Redirect("/Home/Hearings"); Response.Redirect("/Home/Hearings");
} }
[HttpPost] [HttpPost]
public void DeleteHearing(int id) public void DeleteHearing(int id)
{ {
if (APIClient.Guarantor == null) if (APIClient.Guarantor == null)
{ {
throw new Exception("Вы как суда попали? Суда вход только авторизованным"); throw new Exception("Вы как суда попали? Суда вход только авторизованным");
} }
APIClient.PostRequest("api/hearing/deletehearing", new HearingBindingModel APIClient.PostRequest("api/hearing/deletehearing", new HearingBindingModel
{ {
Id = id Id = id
}); });
Response.Redirect("/Home/Hearings"); Response.Redirect("/Home/Hearings");
} }
[HttpGet] [HttpGet]
public IActionResult LawyerHearingCounts() public IActionResult LawyerHearingCounts()
{ {
if (APIClient.Guarantor == null) if (APIClient.Guarantor == null)
{ {
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
using (var context = new LawCompanyDatabase()) using (var context = new LawCompanyDatabase())
{ {
var lawyers = context.Lawyers var lawyers = context.Lawyers
.Where(c => c.GuarantorId == APIClient.Guarantor.Id) .Where(c => c.GuarantorId == APIClient.Guarantor.Id)
.Select(c => new LawyerViewModel .Select(c => new LawyerViewModel
{ {
Id = c.Id, Id = c.Id,
FIO = c.FIO, FIO = c.FIO,
Email = c.Email, Email = c.Email,
Phone = c.Phone, Phone = c.Phone,
GuarantorId = c.GuarantorId GuarantorId = c.GuarantorId
}) })
.ToList(); .ToList();
var lawyerHearingCounts = lawyers.Select(lawyer => new LawyerHearingCountViewModel var lawyerHearingCounts = lawyers.Select(lawyer => new LawyerHearingCountViewModel
{ {
FIO = lawyer.FIO, FIO = lawyer.FIO,
HearingCount = context.HearingLawyers.Count(vc => vc.LawyerId == lawyer.Id) HearingCount = context.HearingLawyers.Count(vc => vc.LawyerId == lawyer.Id)
}).ToList(); }).ToList();
ViewBag.LawyerHearingCounts = lawyerHearingCounts; ViewBag.LawyerHearingCounts = lawyerHearingCounts;
return View(lawyerHearingCounts); return View(lawyerHearingCounts);
} }
} }
} }
} }

View File

@ -7,102 +7,102 @@ using System.Diagnostics;
namespace LawCompanyGuarantorApp.Controllers namespace LawCompanyGuarantorApp.Controllers
{ {
public class HomeController : Controller public class HomeController : Controller
{ {
private readonly ILogger<HomeController> _logger; private readonly ILogger<HomeController> _logger;
private readonly IReportGuarantorLogic _report; private readonly IReportGuarantorLogic _report;
public HomeController(ILogger<HomeController> logger, IReportGuarantorLogic report) public HomeController(ILogger<HomeController> logger, IReportGuarantorLogic report)
{ {
_logger = logger; _logger = logger;
_report = report; _report = report;
} }
public IActionResult Index() public IActionResult Index()
{ {
if (APIClient.Guarantor == null) if (APIClient.Guarantor == null)
{ {
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
return View(); return View();
} }
public IActionResult Register() public IActionResult Register()
{ {
return View(); return View();
} }
[HttpPost] [HttpPost]
public void Register(string fio, string email, string password) public void Register(string fio, string email, string password)
{ {
if (string.IsNullOrEmpty(fio) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) if (string.IsNullOrEmpty(fio) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
{ {
throw new Exception("Введите фио, почту и пароль"); throw new Exception("Введите фио, почту и пароль");
} }
APIClient.PostRequest("api/guarantor/register", new ExecutorBindingModel APIClient.PostRequest("api/guarantor/register", new ExecutorBindingModel
{ {
FIO = fio, FIO = fio,
Email = email, Email = email,
Password = password, Password = password,
}); });
Response.Redirect("Enter"); Response.Redirect("Enter");
return; return;
} }
public IActionResult Enter() public IActionResult Enter()
{ {
return View(); return View();
} }
[HttpPost] [HttpPost]
public void Enter(string email, string password) public void Enter(string email, string password)
{ {
if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
{ {
throw new Exception("Введите email и пароль"); throw new Exception("Введите email и пароль");
} }
APIClient.Guarantor = APIClient.GetRequest<GuarantorViewModel>($"api/guarantor/login?login={email}&password={password}"); APIClient.Guarantor = APIClient.GetRequest<GuarantorViewModel>($"api/guarantor/login?login={email}&password={password}");
if (APIClient.Guarantor == null) if (APIClient.Guarantor == null)
{ {
throw new Exception("Неверный логин/пароль"); throw new Exception("Неверный логин/пароль");
} }
Response.Redirect("Index"); Response.Redirect("Index");
} }
public IActionResult Privacy() public IActionResult Privacy()
{ {
if (APIClient.Guarantor == null) if (APIClient.Guarantor == null)
{ {
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
return View(APIClient.Guarantor); return View(APIClient.Guarantor);
} }
[HttpPost] [HttpPost]
public void Privacy(string fio, string email, string password) public void Privacy(string fio, string email, string password)
{ {
if (APIClient.Guarantor == null) if (APIClient.Guarantor == null)
{ {
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
} }
if (string.IsNullOrEmpty(fio) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) if (string.IsNullOrEmpty(fio) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
{ {
throw new Exception("Введите фио, почту и пароль"); throw new Exception("Введите фио, почту и пароль");
} }
APIClient.PostRequest("api/guarantor/updatedata", new ExecutorBindingModel APIClient.PostRequest("api/guarantor/updatedata", new ExecutorBindingModel
{ {
Id = APIClient.Guarantor.Id, Id = APIClient.Guarantor.Id,
FIO = fio, FIO = fio,
Password = password, Password = password,
Email = email, Email = email,
}); });
APIClient.Guarantor.FIO = fio; APIClient.Guarantor.FIO = fio;
APIClient.Guarantor.Email = email; APIClient.Guarantor.Email = email;
APIClient.Guarantor.Password = password; APIClient.Guarantor.Password = password;
Response.Redirect("Index"); Response.Redirect("Index");
} }
// СТРАНИЦЫ КОНСУЛЬТАЦИЙ // СТРАНИЦЫ КОНСУЛЬТАЦИЙ
public IActionResult Consultations() public IActionResult Consultations()
@ -164,190 +164,190 @@ namespace LawCompanyGuarantorApp.Controllers
Response.Redirect("Index"); Response.Redirect("Index");
} }
[HttpGet] [HttpGet]
public IActionResult LawyerConsultationToFile() public IActionResult LawyerConsultationToFile()
{ {
if (APIClient.Guarantor == null) if (APIClient.Guarantor == null)
{ {
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
return View(APIClient.GetRequest<List<LawyerViewModel>>($"api/lawyer/getlawyerlist?guarantorId={APIClient.Guarantor.Id}")); return View(APIClient.GetRequest<List<LawyerViewModel>>($"api/lawyer/getlawyerlist?guarantorId={APIClient.Guarantor.Id}"));
} }
[HttpPost] [HttpPost]
public void LawyerConsultationToFile(int[] Ids, string type) public void LawyerConsultationToFile(int[] Ids, string type)
{ {
if (APIClient.Guarantor == null) if (APIClient.Guarantor == null)
{ {
throw new Exception("Вы как суда попали? Суда вход только авторизованным"); throw new Exception("Вы как суда попали? Суда вход только авторизованным");
} }
if (Ids.Length <= 0) if (Ids.Length <= 0)
{ {
throw new Exception("Количество должно быть больше 0"); throw new Exception("Количество должно быть больше 0");
} }
if (string.IsNullOrEmpty(type)) if (string.IsNullOrEmpty(type))
{ {
throw new Exception("Неверный тип отчета"); throw new Exception("Неверный тип отчета");
} }
List<int> res = new List<int>(); List<int> res = new List<int>();
foreach (var item in Ids) foreach (var item in Ids)
{ {
res.Add(item); res.Add(item);
} }
if (type == "docx") if (type == "docx")
{ {
APIClient.PostRequest("api/report/CreateGuarantorReportToWordFile", new ReportGuarantorBindingModel APIClient.PostRequest("api/report/CreateGuarantorReportToWordFile", new ReportGuarantorBindingModel
{ {
Ids = res, Ids = res,
FileName = "C:\\Reports\\wordfile.docx" FileName = "C:\\Reports\\wordfile.docx"
}); });
Response.Redirect("GetWordFile"); Response.Redirect("GetWordFile");
} }
else else
{ {
APIClient.PostRequest("api/report/CreateGuarantorReportToExcelFile", new ReportGuarantorBindingModel APIClient.PostRequest("api/report/CreateGuarantorReportToExcelFile", new ReportGuarantorBindingModel
{ {
Ids = res, Ids = res,
FileName = "C:\\Reports\\excelfile.xlsx" FileName = "C:\\Reports\\excelfile.xlsx"
}); });
Response.Redirect("GetExcelFile"); Response.Redirect("GetExcelFile");
} }
} }
[HttpGet] [HttpGet]
public IActionResult GetWordFile() public IActionResult GetWordFile()
{ {
return new PhysicalFileResult("C:\\Reports\\wordfile.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"); return new PhysicalFileResult("C:\\Reports\\wordfile.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
} }
[HttpGet] [HttpGet]
public IActionResult GetExcelFile() public IActionResult GetExcelFile()
{ {
return new PhysicalFileResult("C:\\Reports\\excelfile.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); return new PhysicalFileResult("C:\\Reports\\excelfile.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
} }
public IActionResult GetPdfFile() public IActionResult GetPdfFile()
{ {
return new PhysicalFileResult("C:\\Reports\\pdffile.pdf", "application/pdf"); return new PhysicalFileResult("C:\\Reports\\pdffile.pdf", "application/pdf");
} }
[HttpGet] [HttpGet]
public IActionResult LawyersToPdfFile() public IActionResult LawyersToPdfFile()
{ {
if (APIClient.Guarantor == null) if (APIClient.Guarantor == null)
{ {
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
return View("LawyersToPdfFile"); return View("LawyersToPdfFile");
} }
[HttpPost] [HttpPost]
public void LawyersToPdfFile(DateTime dateFrom, DateTime dateTo, string email) public void LawyersToPdfFile(DateTime dateFrom, DateTime dateTo, string email)
{ {
if (APIClient.Guarantor == null) if (APIClient.Guarantor == null)
{ {
throw new Exception("Вы как суда попали? Суда вход только авторизованным"); throw new Exception("Вы как суда попали? Суда вход только авторизованным");
} }
if (string.IsNullOrEmpty(email)) if (string.IsNullOrEmpty(email))
{ {
throw new Exception("Email пуст"); throw new Exception("Email пуст");
} }
APIClient.PostRequest("api/report/CreateGuarantorReportToPdfFile", new ReportGuarantorBindingModel APIClient.PostRequest("api/report/CreateGuarantorReportToPdfFile", new ReportGuarantorBindingModel
{ {
DateFrom = dateFrom, DateFrom = dateFrom,
DateTo = dateTo, DateTo = dateTo,
GuarantorId = APIClient.Guarantor.Id GuarantorId = APIClient.Guarantor.Id
}); });
APIClient.PostRequest("api/report/SendPdfToMail", new MailSendInfoBindingModel APIClient.PostRequest("api/report/SendPdfToMail", new MailSendInfoBindingModel
{ {
MailAddress = email, MailAddress = email,
Subject = "Отчет по юристам (pdf)", Subject = "Отчет по юристам (pdf)",
Text = "Отчет по юристам с " + dateFrom.ToShortDateString() + " до " + dateTo.ToShortDateString() Text = "Отчет по юристам с " + dateFrom.ToShortDateString() + " до " + dateTo.ToShortDateString()
}); });
Response.Redirect("LawyersToPdfFile"); Response.Redirect("LawyersToPdfFile");
} }
[HttpGet] [HttpGet]
public string GetLawyersReport(DateTime dateFrom, DateTime dateTo) public string GetLawyersReport(DateTime dateFrom, DateTime dateTo)
{ {
if (APIClient.Guarantor == null) if (APIClient.Guarantor == null)
{ {
throw new Exception("Вы как суда попали? Суда вход только авторизованным"); throw new Exception("Вы как суда попали? Суда вход только авторизованным");
} }
List<ReportLawyersViewModel> result; List<ReportLawyersViewModel> result;
try try
{ {
result = _report.GetLawyers(new ReportGuarantorBindingModel result = _report.GetLawyers(new ReportGuarantorBindingModel
{ {
GuarantorId = APIClient.Guarantor.Id, GuarantorId = APIClient.Guarantor.Id,
DateFrom = dateFrom, DateFrom = dateFrom,
DateTo = dateTo DateTo = dateTo
}); });
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка создания отчета"); _logger.LogError(ex, "Ошибка создания отчета");
throw; throw;
} }
string table = ""; string table = "";
table += "<h2 class=\"text-custom-color-1\">Предварительный отчет</h2>"; table += "<h2 class=\"text-custom-color-1\">Предварительный отчет</h2>";
table += "<div class=\"table-responsive\">"; table += "<div class=\"table-responsive\">";
table += "<table class=\"table table-striped table-bordered table-hover\">"; table += "<table class=\"table table-striped table-bordered table-hover\">";
table += "<thead class=\"table-dark\">"; table += "<thead class=\"table-dark\">";
table += "<tr>"; table += "<tr>";
table += "<th scope=\"col\">Юрист</th>"; table += "<th scope=\"col\">Юрист</th>";
table += "<th scope=\"col\">Цена консультации</th>"; table += "<th scope=\"col\">Цена консультации</th>";
table += "<th scope=\"col\">Дата консультации</th>"; table += "<th scope=\"col\">Дата консультации</th>";
table += "<th scope=\"col\">Суд</th>"; table += "<th scope=\"col\">Суд</th>";
table += "<th scope=\"col\">Дата слушания</th>"; table += "<th scope=\"col\">Дата слушания</th>";
table += "</tr>"; table += "</tr>";
table += "</thead>"; table += "</thead>";
foreach (var lawyer in result) foreach (var lawyer in result)
{ {
table += "<tbody>"; table += "<tbody>";
table += "<tr>"; table += "<tr>";
table += $"<td>{lawyer.FIO}</td>"; table += $"<td>{lawyer.FIO}</td>";
table += $"<td></td>"; table += $"<td></td>";
table += $"<td></td>"; table += $"<td></td>";
table += $"<td></td>"; table += $"<td></td>";
table += $"<td></td>"; table += $"<td></td>";
table += "</tr>"; table += "</tr>";
foreach (var cons in lawyer.Consultation) foreach (var cons in lawyer.Consultation)
{ {
table += "<tr>"; table += "<tr>";
table += $"<td></td>"; table += $"<td></td>";
table += $"<td>{cons.ConsultationDate}</td>"; table += $"<td>{cons.ConsultationDate}</td>";
table += $"<td>{cons.Price}</td>"; table += $"<td>{cons.Price}</td>";
table += $"<td></td>"; table += $"<td></td>";
table += $"<td></td>"; table += $"<td></td>";
table += "</tr>"; table += "</tr>";
} }
foreach (var hear in lawyer.Hearing) foreach (var hear in lawyer.Hearing)
{ {
table += "<tr>"; table += "<tr>";
table += $"<td></td>"; table += $"<td></td>";
table += $"<td></td>"; table += $"<td></td>";
table += $"<td></td>"; table += $"<td></td>";
table += $"<td>{hear.Judge}</td>"; table += $"<td>{hear.Judge}</td>";
table += $"<td>{hear.HearingDate}</td>"; table += $"<td>{hear.HearingDate}</td>";
table += "</tr>"; table += "</tr>";
} }
table += "</tbody>"; table += "</tbody>";
} }
table += "</table>"; table += "</table>";
table += "</div>"; table += "</div>";
return table; return table;
} }
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error() public IActionResult Error()
{ {
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
} }
} }
} }

View File

@ -31,7 +31,7 @@
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="ConsultationCase">Связывание</a> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="ConsultationCase">Связывание</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">Личные данные</a> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
</li> </li>

View File

@ -7,130 +7,130 @@ using Microsoft.AspNetCore.Mvc;
namespace LawCompanyRestApi.Controllers namespace LawCompanyRestApi.Controllers
{ {
[Route("api/[controller]/[action]")] [Route("api/[controller]/[action]")]
[ApiController] [ApiController]
public class ConsultationController : Controller public class ConsultationController : Controller
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IConsultationLogic _logic; private readonly IConsultationLogic _logic;
private readonly ILawyerLogic _lawyerlogic; private readonly ILawyerLogic _lawyerlogic;
public ConsultationController(IConsultationLogic logic, ILogger<ConsultationController> public ConsultationController(IConsultationLogic logic, ILogger<ConsultationController>
logger, ILawyerLogic lawyerLogic) logger, ILawyerLogic lawyerLogic)
{ {
_logger = logger; _logger = logger;
_logic = logic; _logic = logic;
_lawyerlogic = lawyerLogic; _lawyerlogic = lawyerLogic;
} }
[HttpGet] [HttpGet]
public List<ConsultationViewModel>? GetConsultationList(int guarantorId) public List<ConsultationViewModel>? GetConsultationList(int guarantorId)
{ {
try try
{ {
return _logic.ReadList(new ConsultationSearchModel return _logic.ReadList(new ConsultationSearchModel
{ {
GuarantorId = guarantorId GuarantorId = guarantorId
}); });
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка получения списка консультаций"); _logger.LogError(ex, "Ошибка получения списка консультаций");
throw; throw;
} }
} }
[HttpGet] [HttpGet]
public ConsultationViewModel? GetConsultation(int id) public ConsultationViewModel? GetConsultation(int id)
{ {
try try
{ {
var elem = _logic.ReadElement(new ConsultationSearchModel { Id = id, }); var elem = _logic.ReadElement(new ConsultationSearchModel { Id = id, });
if (elem == null) if (elem == null)
{ {
return null; return null;
} }
elem.ConsultationLawyers = null!; elem.ConsultationLawyers = null!;
return elem; return elem;
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка получения списка продуктов"); _logger.LogError(ex, "Ошибка получения списка продуктов");
throw; throw;
} }
} }
[HttpPost] [HttpPost]
public void CreateConsultation(ConsultationBindingModel model) public void CreateConsultation(ConsultationBindingModel model)
{ {
try try
{ {
_logic.Create(model); _logic.Create(model);
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка создания кунсультации"); _logger.LogError(ex, "Ошибка создания кунсультации");
throw; throw;
} }
} }
[HttpPost] [HttpPost]
public void UpdateConsultation(ConsultationBindingModel model) public void UpdateConsultation(ConsultationBindingModel model)
{ {
try try
{ {
_logic.Update(model); _logic.Update(model);
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка обновления консультации"); _logger.LogError(ex, "Ошибка обновления консультации");
throw; throw;
} }
} }
[HttpPost] [HttpPost]
public void DeleteConsultation(ConsultationBindingModel model) public void DeleteConsultation(ConsultationBindingModel model)
{ {
try try
{ {
_logic.Delete(model); _logic.Delete(model);
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка удаления консультации"); _logger.LogError(ex, "Ошибка удаления консультации");
throw; throw;
} }
} }
[HttpPost] [HttpPost]
public void AddLawyerToConsultation(Tuple<ConsultationSearchModel, int> model) public void AddLawyerToConsultation(Tuple<ConsultationSearchModel, int> model)
{ {
try try
{ {
var modelLawyer = _lawyerlogic.ReadElement(new LawyerSearchModel { Id = model.Item2 }); var modelLawyer = _lawyerlogic.ReadElement(new LawyerSearchModel { Id = model.Item2 });
if (modelLawyer != null) { _logic.AddLawyerToConsultation(model.Item1, modelLawyer); } if (modelLawyer != null) { _logic.AddLawyerToConsultation(model.Item1, modelLawyer); }
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка добавления юристов в консультацию"); _logger.LogError(ex, "Ошибка добавления юристов в консультацию");
throw; throw;
} }
} }
[HttpGet] [HttpGet]
public List<LawyerViewModel>? GetLawyerListToConsultation(int conId) public List<LawyerViewModel>? GetLawyerListToConsultation(int conId)
{ {
try try
{ {
return _lawyerlogic.ReadConsultationElementList(new ConsultationSearchModel return _lawyerlogic.ReadConsultationElementList(new ConsultationSearchModel
{ {
Id = conId Id = conId
}); });
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка получения списка юристов консультации"); _logger.LogError(ex, "Ошибка получения списка юристов консультации");
throw; throw;
} }
} }
} }
} }

View File

@ -11,6 +11,6 @@
"SmtpClientPort": "587", "SmtpClientPort": "587",
"PopHost": "pop.gmail.com", "PopHost": "pop.gmail.com",
"PopPort": "995", "PopPort": "995",
"MailLogin": "laba46466@gmail.com", "MailLogin": "lab7yakobchuk@gmail.com",
"MailPassword": "iyin rgai wjdh ocmi" "MailPassword": "scht ahjt fxmx tdpc"
} }