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

View File

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

View File

@ -7,18 +7,18 @@ using Microsoft.EntityFrameworkCore;
namespace LawCompanyDatabaseImplement.Implements
{
public class ConsultationStorage : IConsultationStorage
{
public class ConsultationStorage : IConsultationStorage
{
public List<ConsultationViewModel> 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<ConsultationViewModel> GetFilteredList(ConsultationSearchModel model)
{
if (!model.Id.HasValue && !model.GuarantorId.HasValue)

View File

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

View File

@ -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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Case", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int>("ExecutorId")
.HasColumnType("int");
b.Property<int>("ExecutorId")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<int>("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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.CaseClient", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CaseId")
.HasColumnType("int");
b.Property<int>("CaseId")
.HasColumnType("int");
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<int>("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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("ExecutorId")
.HasColumnType("int");
b.Property<int>("ExecutorId")
.HasColumnType("int");
b.Property<string>("FIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("FIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Phone")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Consultation", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int?>("CaseId")
.HasColumnType("int");
b.Property<int?>("CaseId")
.HasColumnType("int");
b.Property<DateTime>("ConsultationDate")
.HasColumnType("datetime2");
b.Property<DateTime>("ConsultationDate")
.HasColumnType("datetime2");
b.Property<double>("Cost")
.HasColumnType("float");
b.Property<double>("Cost")
.HasColumnType("float");
b.Property<int>("GuarantorId")
.HasColumnType("int");
b.Property<int>("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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.ConsultationLawyer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ConsultationId")
.HasColumnType("int");
b.Property<int>("ConsultationId")
.HasColumnType("int");
b.Property<int>("LawyerId")
.HasColumnType("int");
b.Property<int>("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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Executor", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("FIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("FIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Guarantor", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("FIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("FIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Hearing", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("GuarantorId")
.HasColumnType("int");
b.Property<int>("GuarantorId")
.HasColumnType("int");
b.Property<DateTime>("HearingDate")
.HasColumnType("datetime2");
b.Property<DateTime>("HearingDate")
.HasColumnType("datetime2");
b.Property<string>("Judge")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.HearingLawyer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("HearingId")
.HasColumnType("int");
b.Property<int>("HearingId")
.HasColumnType("int");
b.Property<int>("LawyerId")
.HasColumnType("int");
b.Property<int>("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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Lawyer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("FIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("FIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("GuarantorId")
.HasColumnType("int");
b.Property<int?>("GuarantorId")
.HasColumnType("int");
b.Property<string>("Phone")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Visit", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ExecutorId")
.HasColumnType("int");
b.Property<int>("ExecutorId")
.HasColumnType("int");
b.Property<int?>("HearingId")
.HasColumnType("int");
b.Property<int?>("HearingId")
.HasColumnType("int");
b.Property<DateTime>("VisitDate")
.HasColumnType("datetime2");
b.Property<DateTime>("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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
modelBuilder.Entity("LawCompanyDatabaseImplement.Models.VisitClient", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<int>("VisitId")
.HasColumnType("int");
b.Property<int>("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
}
}
}
}
}

View File

@ -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<int, ILawyerModel> _consultationLawyers = null;
[ForeignKey("ConsultationId")]
public virtual List<ConsultationLawyer> Lawyers { get; set; } = new();
[NotMapped]
public Dictionary<int, ILawyerModel> 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<int, ILawyerModel> _consultationLawyers = null;
[ForeignKey("ConsultationId")]
public virtual List<ConsultationLawyer> Lawyers { get; set; } = new();
[NotMapped]
public Dictionary<int, ILawyerModel> 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;
}
}
}

View File

@ -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<List<ConsultationViewModel>>($"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();
}
}
}

View File

@ -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<List<LawyerViewModel>>($"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<List<LawyerViewModel>>($"api/hearing/getlawyerlisttohearing?hearingId={id}"));
}
[HttpGet]
public IActionResult CreateHearing()
{
if (APIClient.Guarantor == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Lawyers = APIClient.GetRequest<List<LawyerViewModel>>($"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<List<LawyerViewModel>>($"api/lawyer/GetLawyerList?guarantorId={APIClient.Guarantor.Id}");
return View();
}
[HttpPost]
public void CreateHearing(DateTime date, string judge, List<int> clientselect)
{
if (APIClient.Guarantor == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
[HttpPost]
public void CreateHearing(DateTime date, string judge, List<int> clientselect)
{
if (APIClient.Guarantor == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
Dictionary<int, ILawyerModel> client = new Dictionary<int, ILawyerModel>();
foreach (int members in clientselect)
{
client.Add(members, new LawyerSearchModel { Id = members } as ILawyerModel);
}
Dictionary<int, ILawyerModel> client = new Dictionary<int, ILawyerModel>();
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<List<LawyerViewModel>>($"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<List<LawyerViewModel>>($"api/lawyer/GetLawyerList?guarantorId={APIClient.Guarantor.Id}");
return View();
}
[HttpPost]
public void UpdateHearing(int id, DateTime date, string judge, List<int> clientselect)
{
if (APIClient.Guarantor == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
[HttpPost]
public void UpdateHearing(int id, DateTime date, string judge, List<int> clientselect)
{
if (APIClient.Guarantor == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
Dictionary<int, ILawyerModel> client = new Dictionary<int, ILawyerModel>();
foreach (int members in clientselect)
{
client.Add(members, new LawyerSearchModel { Id = members } as ILawyerModel);
}
Dictionary<int, ILawyerModel> client = new Dictionary<int, ILawyerModel>();
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);
}
}
}
}

View File

@ -7,102 +7,102 @@ using System.Diagnostics;
namespace LawCompanyGuarantorApp.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
private readonly IReportGuarantorLogic _report;
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
private readonly IReportGuarantorLogic _report;
public HomeController(ILogger<HomeController> logger, IReportGuarantorLogic report)
{
_logger = logger;
_report = report;
}
public HomeController(ILogger<HomeController> 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<GuarantorViewModel>($"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<GuarantorViewModel>($"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<List<LawyerViewModel>>($"api/lawyer/getlawyerlist?guarantorId={APIClient.Guarantor.Id}"));
}
[HttpGet]
public IActionResult LawyerConsultationToFile()
{
if (APIClient.Guarantor == null)
{
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<LawyerViewModel>>($"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<int> res = new List<int>();
List<int> res = new List<int>();
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<ReportLawyersViewModel> 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 += "<h2 class=\"text-custom-color-1\">Предварительный отчет</h2>";
table += "<div class=\"table-responsive\">";
table += "<table class=\"table table-striped table-bordered table-hover\">";
table += "<thead class=\"table-dark\">";
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 += "</tr>";
table += "</thead>";
foreach (var lawyer in result)
{
table += "<tbody>";
table += "<tr>";
table += $"<td>{lawyer.FIO}</td>";
table += $"<td></td>";
table += $"<td></td>";
table += $"<td></td>";
table += $"<td></td>";
table += "</tr>";
foreach (var cons in lawyer.Consultation)
{
table += "<tr>";
table += $"<td></td>";
table += $"<td>{cons.ConsultationDate}</td>";
table += $"<td>{cons.Price}</td>";
table += $"<td></td>";
table += $"<td></td>";
table += "</tr>";
}
foreach (var hear in lawyer.Hearing)
{
table += "<tr>";
table += $"<td></td>";
table += $"<td></td>";
table += $"<td></td>";
table += $"<td>{hear.Judge}</td>";
table += $"<td>{hear.HearingDate}</td>";
table += "</tr>";
}
table += "</tbody>";
}
table += "</table>";
table += "</div>";
return table;
}
[HttpGet]
public string GetLawyersReport(DateTime dateFrom, DateTime dateTo)
{
if (APIClient.Guarantor == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
List<ReportLawyersViewModel> 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 += "<h2 class=\"text-custom-color-1\">Предварительный отчет</h2>";
table += "<div class=\"table-responsive\">";
table += "<table class=\"table table-striped table-bordered table-hover\">";
table += "<thead class=\"table-dark\">";
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 += "</tr>";
table += "</thead>";
foreach (var lawyer in result)
{
table += "<tbody>";
table += "<tr>";
table += $"<td>{lawyer.FIO}</td>";
table += $"<td></td>";
table += $"<td></td>";
table += $"<td></td>";
table += $"<td></td>";
table += "</tr>";
foreach (var cons in lawyer.Consultation)
{
table += "<tr>";
table += $"<td></td>";
table += $"<td>{cons.ConsultationDate}</td>";
table += $"<td>{cons.Price}</td>";
table += $"<td></td>";
table += $"<td></td>";
table += "</tr>";
}
foreach (var hear in lawyer.Hearing)
{
table += "<tr>";
table += $"<td></td>";
table += $"<td></td>";
table += $"<td></td>";
table += $"<td>{hear.Judge}</td>";
table += $"<td>{hear.HearingDate}</td>";
table += "</tr>";
}
table += "</tbody>";
}
table += "</table>";
table += "</div>";
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 });
}
}
}

View File

@ -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<ConsultationController>
logger, ILawyerLogic lawyerLogic)
{
_logger = logger;
_logic = logic;
_lawyerlogic = lawyerLogic;
public ConsultationController(IConsultationLogic logic, ILogger<ConsultationController>
logger, ILawyerLogic lawyerLogic)
{
_logger = logger;
_logic = logic;
_lawyerlogic = lawyerLogic;
}
}
[HttpGet]
public List<ConsultationViewModel>? GetConsultationList(int guarantorId)
{
try
{
return _logic.ReadList(new ConsultationSearchModel
{
GuarantorId = guarantorId
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения списка консультаций");
throw;
}
}
[HttpGet]
public List<ConsultationViewModel>? 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<ConsultationSearchModel, int> 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<LawyerViewModel>? 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<ConsultationSearchModel, int> 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<LawyerViewModel>? GetLawyerListToConsultation(int conId)
{
try
{
return _lawyerlogic.ReadConsultationElementList(new ConsultationSearchModel
{
Id = conId
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения списка юристов консультации");
throw;
}
}
}
}

View File

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