diff --git a/LawCompany/LawCompanyBusinessLogic/OfficePackage/AbstractSaveToPdfGuarantor.cs b/LawCompany/LawCompanyBusinessLogic/OfficePackage/AbstractSaveToPdfGuarantor.cs index f3bb35f..c21caa2 100644 --- a/LawCompany/LawCompanyBusinessLogic/OfficePackage/AbstractSaveToPdfGuarantor.cs +++ b/LawCompany/LawCompanyBusinessLogic/OfficePackage/AbstractSaveToPdfGuarantor.cs @@ -14,82 +14,82 @@ namespace LawCompanyBusinessLogic.OfficePackage { CreatePdf(info); - CreateParagraph(new PdfParagraph - { - Text = info.Title, - Style = "NormalTitle", - ParagraphAlignment = PdfParagraphAlignmentType.Center - }); - CreateParagraph(new PdfParagraph - { - Text = $"с{info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", - Style = "Normal", - ParagraphAlignment = PdfParagraphAlignmentType.Center - }); - CreateTable(new List { "3cm", "5cm", "5cm" }); - CreateRow(new PdfRowParameters - { - Texts = new List { "Юрист", "Цена консультации", "Дата консультации" }, - Style = "NormalTitle", - ParagraphAlignment = PdfParagraphAlignmentType.Center - }); + CreateParagraph(new PdfParagraph + { + Text = info.Title, + Style = "NormalTitle", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + CreateParagraph(new PdfParagraph + { + Text = $"с{info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + CreateTable(new List { "3cm", "5cm", "5cm" }); + CreateRow(new PdfRowParameters + { + Texts = new List { "Юрист", "Цена консультации", "Дата консультации" }, + Style = "NormalTitle", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); - foreach (var ch in info.Lawyers) - { - CreateRow(new PdfRowParameters - { - Texts = new List { ch.FIO, " ", " " }, - Style = "Normal", - ParagraphAlignment = PdfParagraphAlignmentType.Center + foreach (var ch in info.Lawyers) + { + CreateRow(new PdfRowParameters + { + Texts = new List { ch.FIO, " ", " " }, + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Center - }); - foreach (var cons in ch.Consultation) - CreateRow(new PdfRowParameters - { - Texts = new List { " ", cons.Price.ToString() + " рублей", cons.ConsultationDate.ToShortDateString() }, - Style = "Normal", - ParagraphAlignment = PdfParagraphAlignmentType.Center - }); - CreateRow(new PdfRowParameters - { - Texts = new List { " ", " ", "Итого: " + ch.Consultation.Count.ToString() }, - Style = "Normal", - ParagraphAlignment = PdfParagraphAlignmentType.Rigth - }); - } + }); + foreach (var cons in ch.Consultation) + CreateRow(new PdfRowParameters + { + Texts = new List { " ", cons.Price.ToString() + " рублей", cons.ConsultationDate.ToShortDateString() }, + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + CreateRow(new PdfRowParameters + { + Texts = new List { " ", " ", "Итого: " + ch.Consultation.Count.ToString() }, + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Rigth + }); + } - CreateTable(new List { "3cm", "5cm", "5cm" }); - CreateRow(new PdfRowParameters - { - Texts = new List { "Юрист", "Суд", "Дата слушания" }, - Style = "NormalTitle", - ParagraphAlignment = PdfParagraphAlignmentType.Center - }); - foreach (var ch in info.Lawyers) - { - CreateRow(new PdfRowParameters - { - Texts = new List { ch.FIO, " ", " " }, - Style = "Normal", - ParagraphAlignment = PdfParagraphAlignmentType.Center + CreateTable(new List { "3cm", "5cm", "5cm" }); + CreateRow(new PdfRowParameters + { + Texts = new List { "Юрист", "Суд", "Дата слушания" }, + Style = "NormalTitle", + ParagraphAlignment = PdfParagraphAlignmentType.Center + }); + foreach (var ch in info.Lawyers) + { + CreateRow(new PdfRowParameters + { + Texts = new List { ch.FIO, " ", " " }, + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Center - }); - foreach (var hear in ch.Hearing) - CreateRow(new PdfRowParameters - { - Texts = new List { " ", hear.Judge, hear.HearingDate.ToShortDateString() }, - Style = "Normal", - ParagraphAlignment = PdfParagraphAlignmentType.Left - }); - CreateRow(new PdfRowParameters - { - Texts = new List { " ", " ", "Итого: " + ch.Hearing.Count.ToString() }, - Style = "Normal", - ParagraphAlignment = PdfParagraphAlignmentType.Rigth - }); - } - SavePdf(info); - } + }); + foreach (var hear in ch.Hearing) + CreateRow(new PdfRowParameters + { + Texts = new List { " ", hear.Judge, hear.HearingDate.ToShortDateString() }, + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Left + }); + CreateRow(new PdfRowParameters + { + Texts = new List { " ", " ", "Итого: " + ch.Hearing.Count.ToString() }, + Style = "Normal", + ParagraphAlignment = PdfParagraphAlignmentType.Rigth + }); + } + SavePdf(info); + } protected abstract void CreatePdf(PdfInfoGuarantor info); protected abstract void CreateParagraph(PdfParagraph paragraph); diff --git a/LawCompany/LawCompanyContracts/ViewModels/ReportLawyerHearingViewModel.cs b/LawCompany/LawCompanyContracts/ViewModels/ReportLawyerHearingViewModel.cs index 143a122..ae2eb2a 100644 --- a/LawCompany/LawCompanyContracts/ViewModels/ReportLawyerHearingViewModel.cs +++ b/LawCompany/LawCompanyContracts/ViewModels/ReportLawyerHearingViewModel.cs @@ -1,6 +1,6 @@ namespace LawCompanyContracts.ViewModels { - public class ReportLawyerHearingViewModel + public class ReportLawyerHearingViewModel { public string FIO { get; set; } = string.Empty; public List> Visits { get; set; } = new(); diff --git a/LawCompany/LawCompanyDatabaseImplement/Implements/ConsultationStorage.cs b/LawCompany/LawCompanyDatabaseImplement/Implements/ConsultationStorage.cs index 4fdf730..7b43c87 100644 --- a/LawCompany/LawCompanyDatabaseImplement/Implements/ConsultationStorage.cs +++ b/LawCompany/LawCompanyDatabaseImplement/Implements/ConsultationStorage.cs @@ -7,18 +7,18 @@ using Microsoft.EntityFrameworkCore; namespace LawCompanyDatabaseImplement.Implements { - public class ConsultationStorage : IConsultationStorage - { + public class ConsultationStorage : IConsultationStorage + { public List GetFullList() { using var context = new LawCompanyDatabase(); - return context.Consultations - .Include(x => x.Lawyers) - .ThenInclude(x => x.Lawyer) - .ToList() - .Select(x => x.GetViewModel) - .ToList(); - } + return context.Consultations + .Include(x => x.Lawyers) + .ThenInclude(x => x.Lawyer) + .ToList() + .Select(x => x.GetViewModel) + .ToList(); + } public List GetFilteredList(ConsultationSearchModel model) { if (!model.Id.HasValue && !model.GuarantorId.HasValue) diff --git a/LawCompany/LawCompanyDatabaseImplement/LawCompanyDatabase.cs b/LawCompany/LawCompanyDatabaseImplement/LawCompanyDatabase.cs index 2f968ef..2b934a1 100644 --- a/LawCompany/LawCompanyDatabaseImplement/LawCompanyDatabase.cs +++ b/LawCompany/LawCompanyDatabaseImplement/LawCompanyDatabase.cs @@ -15,8 +15,8 @@ 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-7DB3VEN\SQLEXPRESS;Initial Catalog=Test1;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=LawCompanyDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); } diff --git a/LawCompany/LawCompanyDatabaseImplement/Migrations/LawCompanyDatabaseModelSnapshot.cs b/LawCompany/LawCompanyDatabaseImplement/Migrations/LawCompanyDatabaseModelSnapshot.cs index a809813..dca92a1 100644 --- a/LawCompany/LawCompanyDatabaseImplement/Migrations/LawCompanyDatabaseModelSnapshot.cs +++ b/LawCompany/LawCompanyDatabaseImplement/Migrations/LawCompanyDatabaseModelSnapshot.cs @@ -10,525 +10,525 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace LawCompanyDatabaseImplement.Migrations { - [DbContext(typeof(LawCompanyDatabase))] - partial class LawCompanyDatabaseModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { + [DbContext(typeof(LawCompanyDatabase))] + partial class LawCompanyDatabaseModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { #pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.17") - .HasAnnotation("Relational:MaxIdentifierLength", 128); + modelBuilder + .HasAnnotation("ProductVersion", "7.0.17") + .HasAnnotation("Relational:MaxIdentifierLength", 128); - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Case", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Case", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("DateCreate") - .HasColumnType("datetime2"); + b.Property("DateCreate") + .HasColumnType("datetime2"); - b.Property("DateImplement") - .HasColumnType("datetime2"); + b.Property("DateImplement") + .HasColumnType("datetime2"); - b.Property("ExecutorId") - .HasColumnType("int"); + b.Property("ExecutorId") + .HasColumnType("int"); - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.Property("Status") - .HasColumnType("int"); + b.Property("Status") + .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 => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.CaseClient", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("CaseId") - .HasColumnType("int"); + b.Property("CaseId") + .HasColumnType("int"); - b.Property("ClientId") - .HasColumnType("int"); + b.Property("ClientId") + .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 => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.Property("ExecutorId") - .HasColumnType("int"); + b.Property("ExecutorId") + .HasColumnType("int"); - b.Property("FIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("FIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.Property("Phone") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("Phone") + .IsRequired() + .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 => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Consultation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("CaseId") - .HasColumnType("int"); + b.Property("CaseId") + .HasColumnType("int"); - b.Property("ConsultationDate") - .HasColumnType("datetime2"); + b.Property("ConsultationDate") + .HasColumnType("datetime2"); - b.Property("Cost") - .HasColumnType("float"); + b.Property("Cost") + .HasColumnType("float"); - b.Property("GuarantorId") - .HasColumnType("int"); + b.Property("GuarantorId") + .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 => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.ConsultationLawyer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("ConsultationId") - .HasColumnType("int"); + b.Property("ConsultationId") + .HasColumnType("int"); - b.Property("LawyerId") - .HasColumnType("int"); + b.Property("LawyerId") + .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 => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Executor", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.Property("FIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("FIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.HasKey("Id"); + b.HasKey("Id"); - b.ToTable("Executors"); - }); + b.ToTable("Executors"); + }); - modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Guarantor", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Guarantor", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.Property("FIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("FIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.HasKey("Id"); + b.HasKey("Id"); - b.ToTable("Guarantors"); - }); + b.ToTable("Guarantors"); + }); - modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Hearing", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Hearing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("GuarantorId") - .HasColumnType("int"); + b.Property("GuarantorId") + .HasColumnType("int"); - b.Property("HearingDate") - .HasColumnType("datetime2"); + b.Property("HearingDate") + .HasColumnType("datetime2"); - b.Property("Judge") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("Judge") + .IsRequired() + .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 => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.HearingLawyer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("HearingId") - .HasColumnType("int"); + b.Property("HearingId") + .HasColumnType("int"); - b.Property("LawyerId") - .HasColumnType("int"); + b.Property("LawyerId") + .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 => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Lawyer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.Property("FIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("FIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.Property("GuarantorId") - .HasColumnType("int"); + b.Property("GuarantorId") + .HasColumnType("int"); - b.Property("Phone") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("Phone") + .IsRequired() + .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 => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Visit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("ExecutorId") - .HasColumnType("int"); + b.Property("ExecutorId") + .HasColumnType("int"); - b.Property("HearingId") - .HasColumnType("int"); + b.Property("HearingId") + .HasColumnType("int"); - b.Property("VisitDate") - .HasColumnType("datetime2"); + b.Property("VisitDate") + .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 => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.VisitClient", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("ClientId") - .HasColumnType("int"); + b.Property("ClientId") + .HasColumnType("int"); - b.Property("VisitId") - .HasColumnType("int"); + b.Property("VisitId") + .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 => - { - b.HasOne("LawCompanyDatabaseImplement.Models.Executor", null) - .WithMany("Cases") - .HasForeignKey("ExecutorId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Case", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Executor", null) + .WithMany("Cases") + .HasForeignKey("ExecutorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); - modelBuilder.Entity("LawCompanyDatabaseImplement.Models.CaseClient", b => - { - b.HasOne("LawCompanyDatabaseImplement.Models.Case", "Case") - .WithMany("Clients") - .HasForeignKey("CaseId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("LawCompanyDatabaseImplement.Models.Client", "Client") - .WithMany("CaseClients") - .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Case"); - - b.Navigation("Client"); - }); - - modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Client", b => - { - b.HasOne("LawCompanyDatabaseImplement.Models.Executor", "Executor") - .WithMany("Clients") - .HasForeignKey("ExecutorId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Executor"); - }); - - modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Consultation", b => - { - b.HasOne("LawCompanyDatabaseImplement.Models.Case", "Case") - .WithMany() - .HasForeignKey("CaseId"); - - b.HasOne("LawCompanyDatabaseImplement.Models.Guarantor", null) - .WithMany("Consultations") - .HasForeignKey("GuarantorId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Case"); - }); - - modelBuilder.Entity("LawCompanyDatabaseImplement.Models.ConsultationLawyer", b => - { - b.HasOne("LawCompanyDatabaseImplement.Models.Consultation", "Consultation") - .WithMany("Lawyers") - .HasForeignKey("ConsultationId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("LawCompanyDatabaseImplement.Models.Lawyer", "Lawyer") - .WithMany("ConsultationLawyers") - .HasForeignKey("LawyerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Consultation"); - - b.Navigation("Lawyer"); - }); - - modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Hearing", b => - { - b.HasOne("LawCompanyDatabaseImplement.Models.Guarantor", null) - .WithMany("Hearings") - .HasForeignKey("GuarantorId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("LawCompanyDatabaseImplement.Models.HearingLawyer", b => - { - b.HasOne("LawCompanyDatabaseImplement.Models.Hearing", "Hearing") - .WithMany("Lawyers") - .HasForeignKey("HearingId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("LawCompanyDatabaseImplement.Models.Lawyer", "Lawyer") - .WithMany("HearingLawyers") - .HasForeignKey("LawyerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Hearing"); - - b.Navigation("Lawyer"); - }); - - modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Lawyer", b => - { - b.HasOne("LawCompanyDatabaseImplement.Models.Guarantor", null) - .WithMany("Lawyers") - .HasForeignKey("GuarantorId"); - }); - - modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Visit", b => - { - b.HasOne("LawCompanyDatabaseImplement.Models.Executor", null) - .WithMany("Visits") - .HasForeignKey("ExecutorId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("LawCompanyDatabaseImplement.Models.Hearing", "Hearing") - .WithMany() - .HasForeignKey("HearingId"); - - b.Navigation("Hearing"); - }); - - modelBuilder.Entity("LawCompanyDatabaseImplement.Models.VisitClient", b => - { - b.HasOne("LawCompanyDatabaseImplement.Models.Client", "Client") - .WithMany("ClientVisits") - .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("LawCompanyDatabaseImplement.Models.Visit", "Visit") - .WithMany("Clients") - .HasForeignKey("VisitId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Client"); - - b.Navigation("Visit"); - }); - - modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Case", b => - { - b.Navigation("Clients"); - }); - - modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Client", b => - { - b.Navigation("CaseClients"); - - b.Navigation("ClientVisits"); - }); - - modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Consultation", b => - { - b.Navigation("Lawyers"); - }); - - modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Executor", b => - { - b.Navigation("Cases"); - - b.Navigation("Clients"); - - b.Navigation("Visits"); - }); - - modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Guarantor", b => - { - b.Navigation("Consultations"); - - b.Navigation("Hearings"); - - b.Navigation("Lawyers"); - }); - - modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Hearing", b => - { - b.Navigation("Lawyers"); - }); - - modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Lawyer", b => - { - b.Navigation("ConsultationLawyers"); - - b.Navigation("HearingLawyers"); - }); - - modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Visit", b => - { - b.Navigation("Clients"); - }); + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.CaseClient", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Case", "Case") + .WithMany("Clients") + .HasForeignKey("CaseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LawCompanyDatabaseImplement.Models.Client", "Client") + .WithMany("CaseClients") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Case"); + + b.Navigation("Client"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Client", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Executor", "Executor") + .WithMany("Clients") + .HasForeignKey("ExecutorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Executor"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Consultation", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Case", "Case") + .WithMany() + .HasForeignKey("CaseId"); + + b.HasOne("LawCompanyDatabaseImplement.Models.Guarantor", null) + .WithMany("Consultations") + .HasForeignKey("GuarantorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Case"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.ConsultationLawyer", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Consultation", "Consultation") + .WithMany("Lawyers") + .HasForeignKey("ConsultationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LawCompanyDatabaseImplement.Models.Lawyer", "Lawyer") + .WithMany("ConsultationLawyers") + .HasForeignKey("LawyerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Consultation"); + + b.Navigation("Lawyer"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Hearing", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Guarantor", null) + .WithMany("Hearings") + .HasForeignKey("GuarantorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.HearingLawyer", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Hearing", "Hearing") + .WithMany("Lawyers") + .HasForeignKey("HearingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LawCompanyDatabaseImplement.Models.Lawyer", "Lawyer") + .WithMany("HearingLawyers") + .HasForeignKey("LawyerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Hearing"); + + b.Navigation("Lawyer"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Lawyer", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Guarantor", null) + .WithMany("Lawyers") + .HasForeignKey("GuarantorId"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Visit", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Executor", null) + .WithMany("Visits") + .HasForeignKey("ExecutorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LawCompanyDatabaseImplement.Models.Hearing", "Hearing") + .WithMany() + .HasForeignKey("HearingId"); + + b.Navigation("Hearing"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.VisitClient", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Client", "Client") + .WithMany("ClientVisits") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LawCompanyDatabaseImplement.Models.Visit", "Visit") + .WithMany("Clients") + .HasForeignKey("VisitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + + b.Navigation("Visit"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Case", b => + { + b.Navigation("Clients"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Client", b => + { + b.Navigation("CaseClients"); + + b.Navigation("ClientVisits"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Consultation", b => + { + b.Navigation("Lawyers"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Executor", b => + { + b.Navigation("Cases"); + + b.Navigation("Clients"); + + b.Navigation("Visits"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Guarantor", b => + { + b.Navigation("Consultations"); + + b.Navigation("Hearings"); + + b.Navigation("Lawyers"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Hearing", b => + { + b.Navigation("Lawyers"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Lawyer", b => + { + b.Navigation("ConsultationLawyers"); + + b.Navigation("HearingLawyers"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Visit", b => + { + b.Navigation("Clients"); + }); #pragma warning restore 612, 618 - } - } + } + } } diff --git a/LawCompany/LawCompanyDatabaseImplement/Models/Consultation.cs b/LawCompany/LawCompanyDatabaseImplement/Models/Consultation.cs index 2a6bc6d..ede7f2b 100644 --- a/LawCompany/LawCompanyDatabaseImplement/Models/Consultation.cs +++ b/LawCompany/LawCompanyDatabaseImplement/Models/Consultation.cs @@ -7,79 +7,79 @@ using System.ComponentModel.DataAnnotations; namespace LawCompanyDatabaseImplement.Models { - public class Consultation : IConsultationModel - { - public int Id { get; private set; } - [Required] - public double Cost { get; private set; } - [Required] - public DateTime ConsultationDate { get; private set; } - public int? CaseId { get; private set; } - public Case Case { get; private set; } - public int GuarantorId { get; set; } + public class Consultation : IConsultationModel + { + public int Id { get; private set; } + [Required] + public double Cost { get; private set; } + [Required] + public DateTime ConsultationDate { get; private set; } + public int? CaseId { get; private set; } + public Case Case { get; private set; } + public int GuarantorId { get; set; } - private Dictionary _consultationLawyers = null; - [ForeignKey("ConsultationId")] - public virtual List Lawyers { get; set; } = new(); - [NotMapped] - public Dictionary ConsultationLawyers - { - get - { - if (_consultationLawyers == null) - { - _consultationLawyers = Lawyers.ToDictionary(x => x.LawyerId, x => (x.Lawyer as ILawyerModel)); - } - return _consultationLawyers; - } - } - public static Consultation? Create(LawCompanyDatabase context, ConsultationBindingModel? model) - { - if (model == null) - { - return null; - } - return new Consultation() - { - Id = model.Id, - Cost = model.Cost, - ConsultationDate = model.ConsultationDate, - CaseId = model.CaseId, - GuarantorId = model.GuarantorId, - Lawyers = model.ConsultationLawyers.Select(x => new ConsultationLawyer - { - Lawyer = context.Lawyers.First(y => y.Id == x.Key) - }).ToList() - }; - } - public void Update(ConsultationBindingModel? model) - { - using var context = new LawCompanyDatabase(); + private Dictionary _consultationLawyers = null; + [ForeignKey("ConsultationId")] + public virtual List Lawyers { get; set; } = new(); + [NotMapped] + public Dictionary ConsultationLawyers + { + get + { + if (_consultationLawyers == null) + { + _consultationLawyers = Lawyers.ToDictionary(x => x.LawyerId, x => (x.Lawyer as ILawyerModel)); + } + return _consultationLawyers; + } + } + public static Consultation? Create(LawCompanyDatabase context, ConsultationBindingModel? model) + { + if (model == null) + { + return null; + } + return new Consultation() + { + Id = model.Id, + Cost = model.Cost, + ConsultationDate = model.ConsultationDate, + CaseId = model.CaseId, + GuarantorId = model.GuarantorId, + Lawyers = model.ConsultationLawyers.Select(x => new ConsultationLawyer + { + Lawyer = context.Lawyers.First(y => y.Id == x.Key) + }).ToList() + }; + } + public void Update(ConsultationBindingModel? model) + { + using var context = new LawCompanyDatabase(); - if (model == null) - { - return; - } + if (model == null) + { + return; + } - Cost = model.Cost; - ConsultationDate = model.ConsultationDate; - CaseId = model.CaseId; - } - public ConsultationViewModel GetViewModel => new() - { - Id = Id, - Cost = Cost, - ConsultationDate = ConsultationDate, - CaseId = CaseId, - }; + Cost = model.Cost; + ConsultationDate = model.ConsultationDate; + CaseId = model.CaseId; + } + public ConsultationViewModel GetViewModel => new() + { + Id = Id, + Cost = Cost, + ConsultationDate = ConsultationDate, + CaseId = CaseId, + }; - public void UpdateLawyers(LawCompanyDatabase context, ConsultationBindingModel model) - { - var consultationLawyers = context.ConsultationLawyers.Where(rec => rec.ConsultationId == model.Id).ToList(); - if (consultationLawyers != null && consultationLawyers.Count > 0) - { - context.ConsultationLawyers.RemoveRange(consultationLawyers.Where(rec => !model.ConsultationLawyers.ContainsKey(rec.LawyerId))); - context.SaveChanges(); + public void UpdateLawyers(LawCompanyDatabase context, ConsultationBindingModel model) + { + var consultationLawyers = context.ConsultationLawyers.Where(rec => rec.ConsultationId == model.Id).ToList(); + if (consultationLawyers != null && consultationLawyers.Count > 0) + { + context.ConsultationLawyers.RemoveRange(consultationLawyers.Where(rec => !model.ConsultationLawyers.ContainsKey(rec.LawyerId))); + context.SaveChanges(); foreach (var updateMember in consultationLawyers) { @@ -87,17 +87,17 @@ namespace LawCompanyDatabaseImplement.Models } context.SaveChanges(); } - var _consultation = context.Consultations.First(x => x.Id == Id); - foreach (var pc in model.ConsultationLawyers) - { - context.ConsultationLawyers.Add(new ConsultationLawyer - { - Consultation = _consultation, - Lawyer = context.Lawyers.First(x => x.Id == pc.Key), - }); - context.SaveChanges(); - } - _consultationLawyers = null; - } - } + var _consultation = context.Consultations.First(x => x.Id == Id); + foreach (var pc in model.ConsultationLawyers) + { + context.ConsultationLawyers.Add(new ConsultationLawyer + { + Consultation = _consultation, + Lawyer = context.Lawyers.First(x => x.Id == pc.Key), + }); + context.SaveChanges(); + } + _consultationLawyers = null; + } + } } \ No newline at end of file diff --git a/LawCompany/LawCompanyGuarantorApp/Controllers/ConsultationController.cs b/LawCompany/LawCompanyGuarantorApp/Controllers/ConsultationController.cs index 4266327..78fcbc3 100644 --- a/LawCompany/LawCompanyGuarantorApp/Controllers/ConsultationController.cs +++ b/LawCompany/LawCompanyGuarantorApp/Controllers/ConsultationController.cs @@ -105,27 +105,27 @@ namespace LawCompanyGuarantorApp.Controllers Response.Redirect("/Home/Consultations"); } - [HttpGet] - public IActionResult TopConsultation() - { - if (APIClient.Guarantor == null) - { - return Redirect("~/Home/Enter"); - } + [HttpGet] + public IActionResult TopConsultation() + { + if (APIClient.Guarantor == null) + { + return Redirect("~/Home/Enter"); + } var consultation = APIClient.GetRequest>($"api/consultation/GetConsultationList?guarantorId={APIClient.Guarantor.Id}"); - var statusCounts = consultation - .GroupBy(c => c.Cost) - .Select(g => new - { - Cost = g.Key.ToString(), - Count = g.Count() - }) - .ToList(); + var statusCounts = consultation + .GroupBy(c => c.Cost) + .Select(g => new + { + Cost = g.Key.ToString(), + Count = g.Count() + }) + .ToList(); - ViewBag.StatusCounts = statusCounts; + ViewBag.StatusCounts = statusCounts; - return View(); - } - } + return View(); + } + } } \ No newline at end of file diff --git a/LawCompany/LawCompanyGuarantorApp/Controllers/HearingController.cs b/LawCompany/LawCompanyGuarantorApp/Controllers/HearingController.cs index 4845607..d6e8a9d 100644 --- a/LawCompany/LawCompanyGuarantorApp/Controllers/HearingController.cs +++ b/LawCompany/LawCompanyGuarantorApp/Controllers/HearingController.cs @@ -7,137 +7,137 @@ using Microsoft.AspNetCore.Mvc; namespace LawCompanyGuarantorApp.Controllers { - public class HearingController : Controller - { - [HttpGet] - public IActionResult HearingLawyers(int id) - { - if (APIClient.Guarantor == null) - { - return Redirect("~/Home/Enter"); - } - return View(APIClient.GetRequest>($"api/hearing/getlawyerlisttohearing?hearingId={id}")); - } + public class HearingController : Controller + { + [HttpGet] + public IActionResult HearingLawyers(int id) + { + if (APIClient.Guarantor == null) + { + return Redirect("~/Home/Enter"); + } + return View(APIClient.GetRequest>($"api/hearing/getlawyerlisttohearing?hearingId={id}")); + } - [HttpGet] - public IActionResult CreateHearing() - { - if (APIClient.Guarantor == null) - { - return Redirect("~/Home/Enter"); - } - ViewBag.Lawyers = APIClient.GetRequest>($"api/lawyer/GetLawyerList?guarantorId={APIClient.Guarantor.Id}"); - return View(); - } + [HttpGet] + public IActionResult CreateHearing() + { + if (APIClient.Guarantor == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.Lawyers = APIClient.GetRequest>($"api/lawyer/GetLawyerList?guarantorId={APIClient.Guarantor.Id}"); + return View(); + } - [HttpPost] - public void CreateHearing(DateTime date, string judge, List clientselect) - { - if (APIClient.Guarantor == null) - { - throw new Exception("Вы как суда попали? Суда вход только авторизованным"); - } + [HttpPost] + public void CreateHearing(DateTime date, string judge, List clientselect) + { + if (APIClient.Guarantor == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } - Dictionary client = new Dictionary(); - foreach (int members in clientselect) - { - client.Add(members, new LawyerSearchModel { Id = members } as ILawyerModel); - } + Dictionary client = new Dictionary(); + foreach (int members in clientselect) + { + client.Add(members, new LawyerSearchModel { Id = members } as ILawyerModel); + } - APIClient.PostRequest("api/hearing/createhearing", new HearingBindingModel - { - HearingDate = date, - Judge = judge, - HearingLawyers = client, - GuarantorId = APIClient.Guarantor.Id, - }); - Response.Redirect("/Home/Hearings"); - } + APIClient.PostRequest("api/hearing/createhearing", new HearingBindingModel + { + HearingDate = date, + Judge = judge, + HearingLawyers = client, + GuarantorId = APIClient.Guarantor.Id, + }); + Response.Redirect("/Home/Hearings"); + } - [HttpGet] - public IActionResult UpdateHearing() - { - if (APIClient.Guarantor == null) - { - return Redirect("~/Home/Enter"); - } - ViewBag.Lawyers = APIClient.GetRequest>($"api/lawyer/GetLawyerList?guarantorId={APIClient.Guarantor.Id}"); - return View(); - } + [HttpGet] + public IActionResult UpdateHearing() + { + if (APIClient.Guarantor == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.Lawyers = APIClient.GetRequest>($"api/lawyer/GetLawyerList?guarantorId={APIClient.Guarantor.Id}"); + return View(); + } - [HttpPost] - public void UpdateHearing(int id, DateTime date, string judge, List clientselect) - { - if (APIClient.Guarantor == null) - { - throw new Exception("Вы как суда попали? Суда вход только авторизованным"); - } + [HttpPost] + public void UpdateHearing(int id, DateTime date, string judge, List clientselect) + { + if (APIClient.Guarantor == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } - Dictionary client = new Dictionary(); - foreach (int members in clientselect) - { - client.Add(members, new LawyerSearchModel { Id = members } as ILawyerModel); - } + Dictionary client = new Dictionary(); + foreach (int members in clientselect) + { + client.Add(members, new LawyerSearchModel { Id = members } as ILawyerModel); + } - APIClient.PostRequest("api/hearing/updatehearing", new HearingBindingModel - { - Id = id, - HearingDate = date, - Judge = judge, - HearingLawyers = client, - GuarantorId = APIClient.Guarantor.Id, + APIClient.PostRequest("api/hearing/updatehearing", new HearingBindingModel + { + Id = id, + HearingDate = date, + Judge = judge, + HearingLawyers = client, + GuarantorId = APIClient.Guarantor.Id, - }); - Response.Redirect("/Home/Hearings"); - } + }); + Response.Redirect("/Home/Hearings"); + } - [HttpPost] - public void DeleteHearing(int id) - { - if (APIClient.Guarantor == null) - { - throw new Exception("Вы как суда попали? Суда вход только авторизованным"); - } + [HttpPost] + public void DeleteHearing(int id) + { + if (APIClient.Guarantor == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } - APIClient.PostRequest("api/hearing/deletehearing", new HearingBindingModel - { - Id = id - }); - Response.Redirect("/Home/Hearings"); - } + APIClient.PostRequest("api/hearing/deletehearing", new HearingBindingModel + { + Id = id + }); + Response.Redirect("/Home/Hearings"); + } - [HttpGet] - public IActionResult LawyerHearingCounts() - { - if (APIClient.Guarantor == null) - { - return Redirect("~/Home/Enter"); - } + [HttpGet] + public IActionResult LawyerHearingCounts() + { + if (APIClient.Guarantor == null) + { + return Redirect("~/Home/Enter"); + } - using (var context = new LawCompanyDatabase()) - { - var lawyers = context.Lawyers - .Where(c => c.GuarantorId == APIClient.Guarantor.Id) - .Select(c => new LawyerViewModel - { - Id = c.Id, - FIO = c.FIO, - Email = c.Email, - Phone = c.Phone, - GuarantorId = c.GuarantorId - }) - .ToList(); + using (var context = new LawCompanyDatabase()) + { + var lawyers = context.Lawyers + .Where(c => c.GuarantorId == APIClient.Guarantor.Id) + .Select(c => new LawyerViewModel + { + Id = c.Id, + FIO = c.FIO, + Email = c.Email, + Phone = c.Phone, + GuarantorId = c.GuarantorId + }) + .ToList(); - var lawyerHearingCounts = lawyers.Select(lawyer => new LawyerHearingCountViewModel - { - FIO = lawyer.FIO, - HearingCount = context.HearingLawyers.Count(vc => vc.LawyerId == lawyer.Id) - }).ToList(); + var lawyerHearingCounts = lawyers.Select(lawyer => new LawyerHearingCountViewModel + { + FIO = lawyer.FIO, + HearingCount = context.HearingLawyers.Count(vc => vc.LawyerId == lawyer.Id) + }).ToList(); - ViewBag.LawyerHearingCounts = lawyerHearingCounts; + ViewBag.LawyerHearingCounts = lawyerHearingCounts; - return View(lawyerHearingCounts); - } - } - } + return View(lawyerHearingCounts); + } + } + } } \ No newline at end of file diff --git a/LawCompany/LawCompanyGuarantorApp/Controllers/HomeController.cs b/LawCompany/LawCompanyGuarantorApp/Controllers/HomeController.cs index 7ac2a87..2f2ccf2 100644 --- a/LawCompany/LawCompanyGuarantorApp/Controllers/HomeController.cs +++ b/LawCompany/LawCompanyGuarantorApp/Controllers/HomeController.cs @@ -7,102 +7,102 @@ using System.Diagnostics; namespace LawCompanyGuarantorApp.Controllers { - public class HomeController : Controller - { - private readonly ILogger _logger; - private readonly IReportGuarantorLogic _report; + public class HomeController : Controller + { + private readonly ILogger _logger; + private readonly IReportGuarantorLogic _report; - public HomeController(ILogger logger, IReportGuarantorLogic report) - { - _logger = logger; - _report = report; - } + public HomeController(ILogger logger, IReportGuarantorLogic report) + { + _logger = logger; + _report = report; + } - public IActionResult Index() - { - if (APIClient.Guarantor == null) - { - return Redirect("~/Home/Enter"); - } - return View(); - } + public IActionResult Index() + { + if (APIClient.Guarantor == null) + { + return Redirect("~/Home/Enter"); + } + return View(); + } - public IActionResult Register() - { - return View(); - } + public IActionResult Register() + { + return View(); + } - [HttpPost] - public void Register(string fio, string email, string password) - { - if (string.IsNullOrEmpty(fio) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) - { - throw new Exception("Введите фио, почту и пароль"); - } - APIClient.PostRequest("api/guarantor/register", new ExecutorBindingModel - { - FIO = fio, - Email = email, - Password = password, - }); + [HttpPost] + public void Register(string fio, string email, string password) + { + if (string.IsNullOrEmpty(fio) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) + { + throw new Exception("Введите фио, почту и пароль"); + } + APIClient.PostRequest("api/guarantor/register", new ExecutorBindingModel + { + FIO = fio, + Email = email, + Password = password, + }); - Response.Redirect("Enter"); - return; - } + Response.Redirect("Enter"); + return; + } - public IActionResult Enter() - { - return View(); - } + public IActionResult Enter() + { + return View(); + } - [HttpPost] - public void Enter(string email, string password) - { - if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) - { - throw new Exception("Введите email и пароль"); - } - APIClient.Guarantor = APIClient.GetRequest($"api/guarantor/login?login={email}&password={password}"); - if (APIClient.Guarantor == null) - { - throw new Exception("Неверный логин/пароль"); - } - Response.Redirect("Index"); - } + [HttpPost] + public void Enter(string email, string password) + { + if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) + { + throw new Exception("Введите email и пароль"); + } + APIClient.Guarantor = APIClient.GetRequest($"api/guarantor/login?login={email}&password={password}"); + if (APIClient.Guarantor == null) + { + throw new Exception("Неверный логин/пароль"); + } + Response.Redirect("Index"); + } - public IActionResult Privacy() - { - if (APIClient.Guarantor == null) - { - return Redirect("~/Home/Enter"); - } - return View(APIClient.Guarantor); - } + public IActionResult Privacy() + { + if (APIClient.Guarantor == null) + { + return Redirect("~/Home/Enter"); + } + return View(APIClient.Guarantor); + } - [HttpPost] - public void Privacy(string fio, string email, string password) - { - if (APIClient.Guarantor == null) - { - throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); - } - if (string.IsNullOrEmpty(fio) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) - { - throw new Exception("Введите фио, почту и пароль"); - } - APIClient.PostRequest("api/guarantor/updatedata", new ExecutorBindingModel - { - Id = APIClient.Guarantor.Id, - FIO = fio, - Password = password, - Email = email, - }); + [HttpPost] + public void Privacy(string fio, string email, string password) + { + if (APIClient.Guarantor == null) + { + throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); + } + if (string.IsNullOrEmpty(fio) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) + { + throw new Exception("Введите фио, почту и пароль"); + } + APIClient.PostRequest("api/guarantor/updatedata", new ExecutorBindingModel + { + Id = APIClient.Guarantor.Id, + FIO = fio, + Password = password, + Email = email, + }); - APIClient.Guarantor.FIO = fio; - APIClient.Guarantor.Email = email; - APIClient.Guarantor.Password = password; - Response.Redirect("Index"); - } + APIClient.Guarantor.FIO = fio; + APIClient.Guarantor.Email = email; + APIClient.Guarantor.Password = password; + Response.Redirect("Index"); + } // СТРАНИЦЫ КОНСУЛЬТАЦИЙ public IActionResult Consultations() @@ -164,190 +164,190 @@ namespace LawCompanyGuarantorApp.Controllers Response.Redirect("Index"); } - [HttpGet] - public IActionResult LawyerConsultationToFile() - { - if (APIClient.Guarantor == null) - { - return Redirect("~/Home/Enter"); - } - return View(APIClient.GetRequest>($"api/lawyer/getlawyerlist?guarantorId={APIClient.Guarantor.Id}")); - } + [HttpGet] + public IActionResult LawyerConsultationToFile() + { + if (APIClient.Guarantor == null) + { + return Redirect("~/Home/Enter"); + } + return View(APIClient.GetRequest>($"api/lawyer/getlawyerlist?guarantorId={APIClient.Guarantor.Id}")); + } - [HttpPost] - public void LawyerConsultationToFile(int[] Ids, string type) - { - if (APIClient.Guarantor == null) - { - throw new Exception("Вы как суда попали? Суда вход только авторизованным"); - } + [HttpPost] + public void LawyerConsultationToFile(int[] Ids, string type) + { + if (APIClient.Guarantor == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } - if (Ids.Length <= 0) - { - throw new Exception("Количество должно быть больше 0"); - } + if (Ids.Length <= 0) + { + throw new Exception("Количество должно быть больше 0"); + } - if (string.IsNullOrEmpty(type)) - { - throw new Exception("Неверный тип отчета"); - } + if (string.IsNullOrEmpty(type)) + { + throw new Exception("Неверный тип отчета"); + } - List res = new List(); + List res = new List(); - foreach (var item in Ids) - { - res.Add(item); - } + foreach (var item in Ids) + { + res.Add(item); + } - if (type == "docx") - { - APIClient.PostRequest("api/report/CreateGuarantorReportToWordFile", new ReportGuarantorBindingModel - { - Ids = res, - FileName = "C:\\Reports\\wordfile.docx" - }); - Response.Redirect("GetWordFile"); - } - else - { - APIClient.PostRequest("api/report/CreateGuarantorReportToExcelFile", new ReportGuarantorBindingModel - { - Ids = res, - FileName = "C:\\Reports\\excelfile.xlsx" - }); - Response.Redirect("GetExcelFile"); - } - } + if (type == "docx") + { + APIClient.PostRequest("api/report/CreateGuarantorReportToWordFile", new ReportGuarantorBindingModel + { + Ids = res, + FileName = "C:\\Reports\\wordfile.docx" + }); + Response.Redirect("GetWordFile"); + } + else + { + APIClient.PostRequest("api/report/CreateGuarantorReportToExcelFile", new ReportGuarantorBindingModel + { + Ids = res, + FileName = "C:\\Reports\\excelfile.xlsx" + }); + Response.Redirect("GetExcelFile"); + } + } - [HttpGet] - public IActionResult GetWordFile() - { - return new PhysicalFileResult("C:\\Reports\\wordfile.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"); - } + [HttpGet] + public IActionResult GetWordFile() + { + return new PhysicalFileResult("C:\\Reports\\wordfile.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"); + } - [HttpGet] - public IActionResult GetExcelFile() - { - return new PhysicalFileResult("C:\\Reports\\excelfile.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); - } + [HttpGet] + public IActionResult GetExcelFile() + { + return new PhysicalFileResult("C:\\Reports\\excelfile.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + } - public IActionResult GetPdfFile() - { - return new PhysicalFileResult("C:\\Reports\\pdffile.pdf", "application/pdf"); - } + public IActionResult GetPdfFile() + { + return new PhysicalFileResult("C:\\Reports\\pdffile.pdf", "application/pdf"); + } - [HttpGet] - public IActionResult LawyersToPdfFile() - { - if (APIClient.Guarantor == null) - { - return Redirect("~/Home/Enter"); - } - return View("LawyersToPdfFile"); - } + [HttpGet] + public IActionResult LawyersToPdfFile() + { + if (APIClient.Guarantor == null) + { + return Redirect("~/Home/Enter"); + } + return View("LawyersToPdfFile"); + } - [HttpPost] - public void LawyersToPdfFile(DateTime dateFrom, DateTime dateTo, string email) - { - if (APIClient.Guarantor == null) - { - throw new Exception("Вы как суда попали? Суда вход только авторизованным"); - } - if (string.IsNullOrEmpty(email)) - { - throw new Exception("Email пуст"); - } - APIClient.PostRequest("api/report/CreateGuarantorReportToPdfFile", new ReportGuarantorBindingModel - { - DateFrom = dateFrom, - DateTo = dateTo, - GuarantorId = APIClient.Guarantor.Id - }); - APIClient.PostRequest("api/report/SendPdfToMail", new MailSendInfoBindingModel - { - MailAddress = email, - Subject = "Отчет по юристам (pdf)", - Text = "Отчет по юристам с " + dateFrom.ToShortDateString() + " до " + dateTo.ToShortDateString() - }); - Response.Redirect("LawyersToPdfFile"); - } + [HttpPost] + public void LawyersToPdfFile(DateTime dateFrom, DateTime dateTo, string email) + { + if (APIClient.Guarantor == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + if (string.IsNullOrEmpty(email)) + { + throw new Exception("Email пуст"); + } + APIClient.PostRequest("api/report/CreateGuarantorReportToPdfFile", new ReportGuarantorBindingModel + { + DateFrom = dateFrom, + DateTo = dateTo, + GuarantorId = APIClient.Guarantor.Id + }); + APIClient.PostRequest("api/report/SendPdfToMail", new MailSendInfoBindingModel + { + MailAddress = email, + Subject = "Отчет по юристам (pdf)", + Text = "Отчет по юристам с " + dateFrom.ToShortDateString() + " до " + dateTo.ToShortDateString() + }); + Response.Redirect("LawyersToPdfFile"); + } - [HttpGet] - public string GetLawyersReport(DateTime dateFrom, DateTime dateTo) - { - if (APIClient.Guarantor == null) - { - throw new Exception("Вы как суда попали? Суда вход только авторизованным"); - } - List result; - try - { - result = _report.GetLawyers(new ReportGuarantorBindingModel - { - GuarantorId = APIClient.Guarantor.Id, - DateFrom = dateFrom, - DateTo = dateTo - }); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка создания отчета"); - throw; - } - string table = ""; - table += "

Предварительный отчет

"; - table += "
"; - table += ""; - table += ""; - table += ""; - table += ""; - table += ""; - table += ""; - table += ""; - table += ""; - table += ""; - table += ""; - foreach (var lawyer in result) - { - table += ""; - table += ""; - table += $""; - table += $""; - table += $""; - table += $""; - table += $""; - table += ""; - foreach (var cons in lawyer.Consultation) - { - table += ""; - table += $""; - table += $""; - table += $""; - table += $""; - table += $""; - table += ""; - } - foreach (var hear in lawyer.Hearing) - { - table += ""; - table += $""; - table += $""; - table += $""; - table += $""; - table += $""; - table += ""; - } - table += ""; - } - table += "
ЮристЦена консультацииДата консультацииСудДата слушания
{lawyer.FIO}
{cons.ConsultationDate}{cons.Price}
{hear.Judge}{hear.HearingDate}
"; - table += "
"; - return table; - } + [HttpGet] + public string GetLawyersReport(DateTime dateFrom, DateTime dateTo) + { + if (APIClient.Guarantor == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + List result; + try + { + result = _report.GetLawyers(new ReportGuarantorBindingModel + { + GuarantorId = APIClient.Guarantor.Id, + DateFrom = dateFrom, + DateTo = dateTo + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания отчета"); + throw; + } + string table = ""; + table += "

Предварительный отчет

"; + table += "
"; + table += ""; + table += ""; + table += ""; + table += ""; + table += ""; + table += ""; + table += ""; + table += ""; + table += ""; + table += ""; + foreach (var lawyer in result) + { + table += ""; + table += ""; + table += $""; + table += $""; + table += $""; + table += $""; + table += $""; + table += ""; + foreach (var cons in lawyer.Consultation) + { + table += ""; + table += $""; + table += $""; + table += $""; + table += $""; + table += $""; + table += ""; + } + foreach (var hear in lawyer.Hearing) + { + table += ""; + table += $""; + table += $""; + table += $""; + table += $""; + table += $""; + table += ""; + } + table += ""; + } + table += "
ЮристЦена консультацииДата консультацииСудДата слушания
{lawyer.FIO}
{cons.ConsultationDate}{cons.Price}
{hear.Judge}{hear.HearingDate}
"; + table += "
"; + return table; + } - [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] - public IActionResult Error() - { - return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); - } - } + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + public IActionResult Error() + { + return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); + } + } } diff --git a/LawCompany/LawCompanyGuarantorApp/Views/Shared/_LayoutGuarantor.cshtml b/LawCompany/LawCompanyGuarantorApp/Views/Shared/_LayoutGuarantor.cshtml index bb0cd67..8e4c628 100644 --- a/LawCompany/LawCompanyGuarantorApp/Views/Shared/_LayoutGuarantor.cshtml +++ b/LawCompany/LawCompanyGuarantorApp/Views/Shared/_LayoutGuarantor.cshtml @@ -31,7 +31,7 @@ + diff --git a/LawCompany/LawCompanyRestApi/Controllers/ConsultationController.cs b/LawCompany/LawCompanyRestApi/Controllers/ConsultationController.cs index 2b34540..2e96a98 100644 --- a/LawCompany/LawCompanyRestApi/Controllers/ConsultationController.cs +++ b/LawCompany/LawCompanyRestApi/Controllers/ConsultationController.cs @@ -7,130 +7,130 @@ using Microsoft.AspNetCore.Mvc; namespace LawCompanyRestApi.Controllers { - [Route("api/[controller]/[action]")] - [ApiController] - public class ConsultationController : Controller - { - private readonly ILogger _logger; - private readonly IConsultationLogic _logic; - private readonly ILawyerLogic _lawyerlogic; + [Route("api/[controller]/[action]")] + [ApiController] + public class ConsultationController : Controller + { + private readonly ILogger _logger; + private readonly IConsultationLogic _logic; + private readonly ILawyerLogic _lawyerlogic; - public ConsultationController(IConsultationLogic logic, ILogger - logger, ILawyerLogic lawyerLogic) - { - _logger = logger; - _logic = logic; - _lawyerlogic = lawyerLogic; + public ConsultationController(IConsultationLogic logic, ILogger + logger, ILawyerLogic lawyerLogic) + { + _logger = logger; + _logic = logic; + _lawyerlogic = lawyerLogic; - } + } - [HttpGet] - public List? GetConsultationList(int guarantorId) - { - try - { - return _logic.ReadList(new ConsultationSearchModel - { - GuarantorId = guarantorId - }); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения списка консультаций"); - throw; - } - } + [HttpGet] + public List? GetConsultationList(int guarantorId) + { + try + { + return _logic.ReadList(new ConsultationSearchModel + { + GuarantorId = guarantorId + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка консультаций"); + throw; + } + } - [HttpGet] - public ConsultationViewModel? GetConsultation(int id) - { - try - { - var elem = _logic.ReadElement(new ConsultationSearchModel { Id = id, }); - if (elem == null) - { - return null; - } - elem.ConsultationLawyers = null!; - return elem; - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения списка продуктов"); - throw; - } - } + [HttpGet] + public ConsultationViewModel? GetConsultation(int id) + { + try + { + var elem = _logic.ReadElement(new ConsultationSearchModel { Id = id, }); + if (elem == null) + { + return null; + } + elem.ConsultationLawyers = null!; + return elem; + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка продуктов"); + throw; + } + } - [HttpPost] - public void CreateConsultation(ConsultationBindingModel model) - { + [HttpPost] + public void CreateConsultation(ConsultationBindingModel model) + { - try - { - _logic.Create(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка создания кунсультации"); - throw; - } + try + { + _logic.Create(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания кунсультации"); + throw; + } - } - [HttpPost] - public void UpdateConsultation(ConsultationBindingModel model) - { - try - { - _logic.Update(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка обновления консультации"); - throw; - } - } - [HttpPost] - public void DeleteConsultation(ConsultationBindingModel model) - { - try - { - _logic.Delete(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка удаления консультации"); - throw; - } - } - [HttpPost] - public void AddLawyerToConsultation(Tuple model) - { - try - { - var modelLawyer = _lawyerlogic.ReadElement(new LawyerSearchModel { Id = model.Item2 }); - if (modelLawyer != null) { _logic.AddLawyerToConsultation(model.Item1, modelLawyer); } - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка добавления юристов в консультацию"); - throw; - } - } - [HttpGet] - public List? GetLawyerListToConsultation(int conId) - { - try - { - return _lawyerlogic.ReadConsultationElementList(new ConsultationSearchModel - { - Id = conId - }); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения списка юристов консультации"); - throw; - } - } - } + } + [HttpPost] + public void UpdateConsultation(ConsultationBindingModel model) + { + try + { + _logic.Update(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка обновления консультации"); + throw; + } + } + [HttpPost] + public void DeleteConsultation(ConsultationBindingModel model) + { + try + { + _logic.Delete(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления консультации"); + throw; + } + } + [HttpPost] + public void AddLawyerToConsultation(Tuple model) + { + try + { + var modelLawyer = _lawyerlogic.ReadElement(new LawyerSearchModel { Id = model.Item2 }); + if (modelLawyer != null) { _logic.AddLawyerToConsultation(model.Item1, modelLawyer); } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка добавления юристов в консультацию"); + throw; + } + } + [HttpGet] + public List? GetLawyerListToConsultation(int conId) + { + try + { + return _lawyerlogic.ReadConsultationElementList(new ConsultationSearchModel + { + Id = conId + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка юристов консультации"); + throw; + } + } + } } diff --git a/LawCompany/LawCompanyRestApi/appsettings.json b/LawCompany/LawCompanyRestApi/appsettings.json index f1495d8..5949cde 100644 --- a/LawCompany/LawCompanyRestApi/appsettings.json +++ b/LawCompany/LawCompanyRestApi/appsettings.json @@ -11,6 +11,6 @@ "SmtpClientPort": "587", "PopHost": "pop.gmail.com", "PopPort": "995", - "MailLogin": "laba46466@gmail.com", - "MailPassword": "iyin rgai wjdh ocmi" + "MailLogin": "lab7yakobchuk@gmail.com", + "MailPassword": "scht ahjt fxmx tdpc" }