Compare commits

...

35 Commits

Author SHA1 Message Date
maxnes3
c3a2e129df Удалил implement 2023-05-24 23:30:07 +04:00
maxnes3
33d22bbb24 fix update lawyer 2023-05-20 11:00:13 +04:00
maxnes3
2cca5bd9b9 Ещё немного валидации 2023-05-20 09:55:10 +04:00
maxnes3
92c6c1c503 Мелкие правки 2023-05-20 09:10:45 +04:00
maxnes3
db5681fc25 Добавил диаграмму 2023-05-20 05:04:42 +04:00
maxnes3
636af51602 Пофиксил баги после слияния 2023-05-20 04:14:14 +04:00
2a69fbeb58 mergemerger 2023-05-20 04:05:26 +04:00
maxnes3
9c75a284f7 Осталось чуть-чуть 2023-05-20 04:01:37 +04:00
9dcb619007 Починил "Изменение" и удаление, но не все 2023-05-20 04:01:15 +04:00
maxnes3
740f8ec2ef Ура, почти всё. Чё там с дедлайном?
Мать жива?
2023-05-20 03:13:10 +04:00
202848320e НЕ РАБОТАЕТ 2023-05-20 01:42:29 +04:00
762525822b Не работает список 2023-05-20 01:21:33 +04:00
maxnes3
3134b5f6e1 Работает list 2023-05-20 00:24:04 +04:00
8207be80a7 merge commit 2023-05-19 22:38:29 +04:00
maxnes3
ba1d369a2d Cтранно 2023-05-19 22:34:30 +04:00
900c5f1fb4 Пишу отчеты №1 2023-05-19 22:34:15 +04:00
maxnes3
3aa0265de4 Merge branch 'main' of http://student.git.athene.tech/maxnes3/Case_accounting 2023-05-19 22:34:10 +04:00
maxnes3
7483e0682d Чек 2023-05-19 22:33:41 +04:00
86877b84eb Merge branch 'HelpBench' 2023-05-19 21:28:19 +04:00
7fcf90e006 ПРИВЯЗКУ ДОДЕЛАЛ!! 2023-05-19 21:27:33 +04:00
maxnes3
cc28f399a4 Остались отчёты 2023-05-19 21:07:14 +04:00
cd661669c0 Вроде юрист работает 2023-05-19 20:02:17 +04:00
0c09e52c47 Осталось привязку 2023-05-19 20:01:56 +04:00
1843a431ec Чиним многие-ко-многим 2023-05-19 18:12:37 +04:00
maxnes3
39bc95794b Работает!!!!!! 2023-05-19 18:09:36 +04:00
79071f22b2 Пытаемся прикрутить многие-ко-многим юристы. 2023-05-19 14:53:49 +04:00
maxnes3
f03bb241c0 Промежутный коммит, исправлены баги 2023-05-19 14:39:49 +04:00
4bea770d99 Починили Contracts, Specializations. 2023-05-19 13:20:14 +04:00
maxnes3
f3652285b9 Исправил регистрацию 2023-05-19 02:29:30 +04:00
06f1d54d0d Merge branch 'HelpBench' 2023-05-19 02:12:41 +04:00
2bfd9748d9 Дописал вьюшки, но без многие-ко-многим 2023-05-18 23:42:48 +04:00
5e5fdc43f3 Merge branch 'main' into HelpBench 2023-05-18 16:54:30 +04:00
d698afd31b добавил миграции 2023-05-18 16:54:05 +04:00
f1e340788e Merge branch 'main' into HelpBench 2023-05-18 00:44:45 +04:00
d9af3176b7 BenchFix 2023-05-18 00:43:44 +04:00
220 changed files with 83956 additions and 341 deletions

View File

@ -11,9 +11,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CaseAccountingDataBaseImple
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CaseAccountingBusinessLogic", "CaseAccountingBusinessLogics\CaseAccountingBusinessLogic.csproj", "{4D95FDCC-80B3-452F-86FD-D514655ED0FB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CaseAccountingRestApi", "CaseAccountingRestApi\CaseAccountingRestApi.csproj", "{B7787749-149B-416C-87F2-F00DE8D6C615}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CaseAccountingRestApi", "CaseAccountingRestApi\CaseAccountingRestApi.csproj", "{B7787749-149B-416C-87F2-F00DE8D6C615}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CaseAccountingProviderView", "CaseAccountingProviderView\CaseAccountingProviderView.csproj", "{A7B05A7C-F75B-48B6-BBDF-CDE4597A8258}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CaseAccountingProviderView", "CaseAccountingProviderView\CaseAccountingProviderView.csproj", "{A7B05A7C-F75B-48B6-BBDF-CDE4597A8258}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CaseAccountingCustomerView", "CaseAccountingCustomerView\CaseAccountingCustomerView.csproj", "{96FD88AF-C51B-46FD-999A-7463C74C1339}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -45,6 +47,10 @@ Global
{A7B05A7C-F75B-48B6-BBDF-CDE4597A8258}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A7B05A7C-F75B-48B6-BBDF-CDE4597A8258}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A7B05A7C-F75B-48B6-BBDF-CDE4597A8258}.Release|Any CPU.Build.0 = Release|Any CPU
{96FD88AF-C51B-46FD-999A-7463C74C1339}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{96FD88AF-C51B-46FD-999A-7463C74C1339}.Debug|Any CPU.Build.0 = Debug|Any CPU
{96FD88AF-C51B-46FD-999A-7463C74C1339}.Release|Any CPU.ActiveCfg = Release|Any CPU
{96FD88AF-C51B-46FD-999A-7463C74C1339}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -76,6 +76,11 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
return list;
}
public List<SpecializationCasesViewModel> GetSpecializationCases()
{
return _caseStorage.GetSpecializationCases() ?? new List<SpecializationCasesViewModel>();
}
public bool Update(CaseBindingModel model)
{
CheckModel(model);

View File

@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using CaseAccountingContracts.BindingModels;
namespace CaseAccountingBusinessLogic.BusinessLogics
{
public class MailSender
{
private string mailLogin = string.Empty;
private string mailPassword = string.Empty;
private string smtpClientHost = string.Empty;
private int smtpClientPort;
public MailSender(){}
public void MailConfig(MailConfigBindingModel config)
{
mailLogin = config.MailLogin;
mailPassword = config.MailPassword;
smtpClientHost = config.SmtpClientHost;
smtpClientPort = config.SmtpClientPort;
}
public async void SendMailAsync(MailSendInfoBindingModel info)
{
using var objMailMessage = new MailMessage();
using var objSmtpClient = new SmtpClient(smtpClientHost, smtpClientPort);
try
{
objMailMessage.From = new MailAddress(mailLogin);
objMailMessage.To.Add(new MailAddress(info.MailAddress));
objMailMessage.Subject = info.Subject;
objMailMessage.Body = info.Text;
objMailMessage.SubjectEncoding = Encoding.UTF8;
objMailMessage.BodyEncoding = Encoding.UTF8;
MemoryStream ms = new(info.File);
objMailMessage.Attachments.Add(new Attachment(ms, "report.pdf", "application/pdf"));
objSmtpClient.UseDefaultCredentials = false;
objSmtpClient.EnableSsl = true;
objSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
objSmtpClient.Credentials = new NetworkCredential(mailLogin, mailPassword);
await Task.Run(() => objSmtpClient.Send(objMailMessage));
}
catch (Exception)
{
throw;
}
}
}
}

View File

@ -1,4 +1,6 @@
using CaseAccountingContracts.BindingModels;
using CaseAccountingBusinessLogic.OfficePackage;
using CaseAccountingBusinessLogic.OfficePackage.HelperModels;
using CaseAccountingContracts.BindingModels;
using CaseAccountingContracts.BusinessLogicContracts;
using CaseAccountingContracts.SearchModels;
using CaseAccountingContracts.StoragesContracts;
@ -17,13 +19,18 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
private readonly IHearingStorage _hearingStorage;
private readonly ILawyerStorage _lawyerStorage;
private readonly ISpecializationStorage _specializationStorage;
private readonly WordBuilderCustomer _wordBuilder;
private readonly ExcelBuilderCustomer _excelBuilder;
public ReportCustomerLogic(ICaseStorage caseStorage, IHearingStorage hearingStorage, ILawyerStorage lawyerStorage, ISpecializationStorage specializationStorage)
public ReportCustomerLogic(ICaseStorage caseStorage, IHearingStorage hearingStorage, ILawyerStorage lawyerStorage, ISpecializationStorage specializationStorage,
WordBuilderCustomer wordBuilder, ExcelBuilderCustomer excelBuilder)
{
_caseStorage = caseStorage;
_hearingStorage = hearingStorage;
_lawyerStorage = lawyerStorage;
_specializationStorage = specializationStorage;
_wordBuilder = wordBuilder;
_excelBuilder = excelBuilder;
}
public List<ReportHearingSpecializationViewModel> GetHearingSpecialization(ReportBindingModel model)
@ -45,34 +52,23 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
return result;
}
public List<ReportLawyerHearingViewModel> GetLawyerHearing(List<LawyerViewModel> models)
public List<ReportLawyerHearingViewModel> GetLawyersHearing(List<LawyerViewModel> lawyers)
{
var lawyers = new List<LawyerViewModel>();
foreach (var model in models)
var reportRecords = new List<ReportLawyerHearingViewModel>();
foreach (var lawyer in lawyers)
{
lawyers.Add(_lawyerStorage.GetElement(new LawyerSearchModel { Id = model.Id}));
}
var list = new List<ReportLawyerHearingViewModel>();
foreach(var lawyer in lawyers)
{
var record = new ReportLawyerHearingViewModel
var hearings = _lawyerStorage.GetLawyerCases(new() { Id = lawyer.Id })
.SelectMany(_case => _caseStorage.GetCaseHearings(new() { Id = _case.Id }))
.Select(hearing => hearing.Information)
.ToList();
ReportLawyerHearingViewModel reportRecord = new()
{
Name = lawyer.Name,
Surname = lawyer.Surname,
Patronymic = lawyer.Patronymic,
Hearings = new List<(DateTime Date, string Information)>()
Lawyer = lawyer.Name + " " + lawyer.Surname + ", " + lawyer.Patronymic,
Hearings = hearings
};
var cases = _caseStorage.GetFullList()
.Where(x => x.Lawyers.ContainsKey(lawyer.Id));
foreach (var _case in cases)
{
record.Hearings.Add((_hearingStorage.GetElement(new HearingSearchModel { CaseId = _case.Id}).Date,
_hearingStorage.GetElement(new HearingSearchModel { CaseId = _case.Id })?.Information ?? "Не удалось найти информацию."));
}
list.Add(record);
reportRecords.Add(reportRecord);
}
return list;
return reportRecords;
}
public void SaveHearingSpecializationToPdfFile(ReportBindingModel model)
@ -89,5 +85,28 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
{
throw new NotImplementedException();
}
public byte[] SaveListFile(LawyerHearingListBindingModel model)
{
byte[] file = Array.Empty<byte>();
string title = "Список слушаний по выбранным юристам";
if (model.FileType == "docx")
{
_wordBuilder.CreateDocument();
_wordBuilder.CreateTitle(title);
_wordBuilder.CreateLawyersHearingTable(GetLawyersHearing(model.Lawyers));
file = _wordBuilder.GetFile();
}
else if (model.FileType == "xlsx")
{
_excelBuilder.CreateDocument();
_excelBuilder.CreateTitle(title);
_excelBuilder.CreateLawyersHearingTable(GetLawyersHearing(model.Lawyers));
file = _excelBuilder.GetFile();
}
return file;
}
}
}

View File

@ -1,4 +1,6 @@
using CaseAccountingContracts.BindingModels;
using CaseAccountingBusinessLogic.BusinessLogic.OfficePackage;
using CaseAccountingBusinessLogic.OfficePackage;
using CaseAccountingContracts.BindingModels;
using CaseAccountingContracts.BusinessLogicContracts;
using CaseAccountingContracts.SearchModels;
using CaseAccountingContracts.StoragesContracts;
@ -17,68 +19,135 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
private readonly ISpecializationStorage _specializationStorage;
private readonly IHearingStorage _hearingStorage;
private readonly ILawyerStorage _lawyerStorage;
private readonly WordBuilderProvider _wordBuilder;
private readonly ExcelBuilderProvider _excelBuilder;
private readonly PdfBuilderProvider _pdfBuilder;
private readonly MailSender _mailSender;
public ReportProviderLogic(ICaseStorage caseStorage, ISpecializationStorage specializationStorage, IHearingStorage hearingStorage, ILawyerStorage lawyerStorage)
public ReportProviderLogic(ICaseStorage caseStorage, ISpecializationStorage specializationStorage, IHearingStorage hearingStorage,
ILawyerStorage lawyerStorage, WordBuilderProvider wordBuilder, ExcelBuilderProvider excelBuilder,
PdfBuilderProvider pdfBuilder, MailSender mailSender)
{
_caseStorage = caseStorage ?? throw new ArgumentNullException(nameof(caseStorage));
_specializationStorage = specializationStorage ?? throw new ArgumentNullException(nameof(specializationStorage));
_hearingStorage = hearingStorage ?? throw new ArgumentNullException(nameof(hearingStorage));
_lawyerStorage = lawyerStorage ?? throw new ArgumentNullException(nameof(lawyerStorage));
_wordBuilder = wordBuilder ?? throw new ArgumentNullException(nameof(wordBuilder));
_excelBuilder = excelBuilder ?? throw new ArgumentNullException(nameof(excelBuilder));
_pdfBuilder = pdfBuilder ?? throw new ArgumentNullException(nameof(pdfBuilder));
_mailSender = mailSender ?? throw new ArgumentNullException(nameof(mailSender));
}
public List<ReportCaseSpecializationViewModel> GetCaseSpecialization(List<CaseViewModel> models)
{
var сases = new List<CaseViewModel>();
List<ReportCaseSpecializationViewModel> list = new();
foreach (var model in models)
сases.Add(_caseStorage.GetElement(new CaseSearchModel { Id = model.Id }));
return сases.Select(x => new ReportCaseSpecializationViewModel {
CaseName = x.Name,
Applicant = x.Applicant,
Defendant = x.Defendant,
Date = x.Date,
Specialization = x.Specialization,
}).ToList();
{
var specialization = _specializationStorage.GetElement(new SpecializationSearchModel { Id = model.SpecializationId });
var caseModel = _caseStorage.GetElement(new CaseSearchModel { Id = model.Id });
if (specialization == null)
{
throw new Exception("Некоректные данные по специализации");
}
if (caseModel == null)
{
throw new Exception("Некоректные данные по делу");
}
bool hasSpec = false;
if (list.Count > 0)
{
foreach (var report in list)
{
if (hasSpec = report.Specialization.Equals(specialization.Name))
{
report.Cases.Add("Дело #" + caseModel.Id.ToString());
break;
}
}
}
if (!hasSpec)
{
var newElement = new ReportCaseSpecializationViewModel
{
Specialization = specialization.Name,
Cases = new()
};
newElement.Cases.Add("Дело #" + caseModel.Id.ToString());
list.Add(newElement);
}
}
return list;
}
public List<ReportHearingLawyerViewModel> GetHearingLawyer(ReportBindingModel model)
{
var hearings = _hearingStorage
.GetFilteredList(new HearingSearchModel { UserId = model.UserId})
.GetFilteredList(new HearingSearchModel { UserId = model.UserId })
.Where(x => model.DateFrom <= x.Date && model.DateTo >= x.Date);
var list = new List<ReportHearingLawyerViewModel>();
foreach (var hearing in hearings)
{
var record = new ReportHearingLawyerViewModel
{
Information = hearing.Information,
Date = hearing.Date,
Lawyers = new List<(string Surname, string Name, string Patronymic)>()
Hearing = "Номер слушания #" + hearing.Id.ToString(),
CaseLawyers = new()
};
foreach (var lawyer in _caseStorage.GetElement(new CaseSearchModel { Id = hearing.CaseId }).Lawyers.Values)
var caseId = _caseStorage.GetElement(new CaseSearchModel { Id = hearing.CaseId }).Id;
foreach (var lawyer in _lawyerStorage.GetLawyerMTM(caseId))
{
record.Lawyers.Add((lawyer.Surname, lawyer.Name, lawyer.Patronymic));
record.CaseLawyers.Add(new CaseLawyerViewModel
{
Case = "Дело #" + caseId.ToString(),
Date = hearing.Date,
Lawyer = lawyer.Surname + " " + lawyer.Name + " " + lawyer.Patronymic
});
}
list.Add(record);
}
return list;
}
public void SaveCaseSpecializationToExcelFile(ReportBindingModel model)
public byte[] SaveListFile(CaseSpecializationListBindingModel model)
{
throw new NotImplementedException();
//TODO
byte[] file = Array.Empty<byte>();
string title = "Список специализаций по выбраным делам";
if (model.FileType == "docx")
{
_wordBuilder.CreateDocument();
_wordBuilder.CreateTitle(title);
_wordBuilder.CreateCaseSpecializationTable(GetCaseSpecialization(model.Cases));
file = _wordBuilder.GetFile();
}
else if (model.FileType == "xlsx")
{
_excelBuilder.CreateDocument();
_excelBuilder.CreateTitle(title);
_excelBuilder.CreateCaseSpecializationTable(GetCaseSpecialization(model.Cases));
file = _excelBuilder.GetFile();
}
return file;
}
public void SaveCaseSpecializationToWordFile(ReportBindingModel model)
public void SendByMailStatusReport(ReportBindingModel reportModel)
{
throw new NotImplementedException();
//TODO
}
public void SaveHearingLawyerToPdfFile(ReportBindingModel model)
{
throw new NotImplementedException();
//TODO
byte[] file = _pdfBuilder.GetHearingLawyerReportFile(new()
{
Title = "Отчет по слушаниям",
DateFrom = reportModel.DateFrom,
DateTo = reportModel.DateTo,
Records = GetHearingLawyer(reportModel)
});
_mailSender.SendMailAsync(new()
{
MailAddress = reportModel.UserEmail,
Subject = "Отчет по слушаниям",
Text = $"За период с {reportModel.DateFrom.ToShortDateString()} " +
$"по {reportModel.DateTo.ToShortDateString()}.",
File = file
});
}
}
}

View File

@ -7,18 +7,28 @@
</PropertyGroup>
<ItemGroup>
<Compile Remove="OfficePackage\Implements\**" />
<EmbeddedResource Remove="OfficePackage\Implements\**" />
<None Remove="OfficePackage\Implements\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CaseAccountingContracts\CaseAccountingContracts.csproj" />
<ProjectReference Include="..\CaseAccountingDataBaseImplement\CaseAccountingDataBaseImplement.csproj" />
<ProjectReference Include="..\CaseAccountingDataModels\CaseAccountingDataModels.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="OfficePackage\HelperEnums\" />
<Folder Include="OfficePackage\HelperModels\" />
<Folder Include="OfficePackage\Implements\" />
</ItemGroup>
</Project>

View File

@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CaseAccountingBusinessLogic.OfficePackage
{
public class AbstractSaveToExcelCustomer
{
}
}

View File

@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CaseAccountingBusinessLogic.OfficePackage
{
public class AbstractSaveToExcelProvider
{
}
}

View File

@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CaseAccountingBusinessLogic.OfficePackage
{
public class AbstractSaveToPdfCustomer
{
}
}

View File

@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CaseAccountingBusinessLogic.OfficePackage
{
public class AbstractSaveToPdfProvider
{
}
}

View File

@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CaseAccountingBusinessLogic.OfficePackage
{
public class AbstractSaveToWordCustomer
{
}
}

View File

@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CaseAccountingBusinessLogic.OfficePackage
{
public class AbstractSaveToWordProvider
{
}
}

View File

@ -0,0 +1,361 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CaseAccountingBusinessLogic.OfficePackage.HelperModels;
using CaseAccountingContracts.ViewModels;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
namespace CaseAccountingBusinessLogic.OfficePackage
{
public class ExcelBuilderCustomer
{
private readonly string tempFileName = "temp.xlsx";
private SpreadsheetDocument? spreadsheetDocument;
private SharedStringTablePart? shareStringPart;
private Worksheet? worksheet;
private void CreateStyles(WorkbookPart workbookpart)
{
var sp = workbookpart.AddNewPart<WorkbookStylesPart>();
sp.Stylesheet = new Stylesheet();
var fonts = new Fonts() { Count = 2U, KnownFonts = true };
var fontUsual = new Font();
fontUsual.Append(new FontSize() { Val = 12D });
fonts.Append(fontUsual);
var fontTitle = new Font();
fontTitle.Append(new Bold());
fontTitle.Append(new FontSize() { Val = 12D });
fonts.Append(fontTitle);
var fills = new Fills() { Count = 3U };
var fill1 = new Fill();
fill1.Append(new PatternFill()
{
PatternType = PatternValues.None
});
var fill2 = new Fill();
fill2.Append(new PatternFill()
{
PatternType = PatternValues.Gray125
});
var fill3 = new Fill();
fill3.Append(new PatternFill()
{
PatternType = PatternValues.Solid,
ForegroundColor = new()
{
Rgb = "e0e8ff"
}
});
var fill4 = new Fill();
fill1.Append(new PatternFill()
{
PatternType = PatternValues.None
});
fills.Append(fill1);
fills.Append(fill2);
fills.Append(fill3);
fills.Append(fill4);
var borders = new Borders() { Count = 2U };
var borderNoBorder = new Border();
borderNoBorder.Append(new LeftBorder());
borderNoBorder.Append(new RightBorder());
borderNoBorder.Append(new TopBorder());
borderNoBorder.Append(new BottomBorder());
borderNoBorder.Append(new DiagonalBorder());
var borderThin = new Border();
var leftBorder = new LeftBorder() { Style = BorderStyleValues.Thin };
leftBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
var rightBorder = new RightBorder() { Style = BorderStyleValues.Thin };
rightBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
var topBorder = new TopBorder() { Style = BorderStyleValues.Thin };
topBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
var bottomBorder = new BottomBorder() { Style = BorderStyleValues.Thin };
bottomBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
borderThin.Append(leftBorder);
borderThin.Append(rightBorder);
borderThin.Append(topBorder);
borderThin.Append(bottomBorder);
borderThin.Append(new DiagonalBorder());
borders.Append(borderNoBorder);
borders.Append(borderThin);
CellFormats cellFormats = new() { Count = 4U };
CellFormat cellFormatEmpty = new()
{
FontId = 0U,
FillId = 0U,
BorderId = 1U,
ApplyFont = true
};
CellFormat cellFormatDefault = new()
{
FontId = 0U,
FillId = 3U,
BorderId = 1U,
ApplyFont = true
};
CellFormat cellFormatTitle = new()
{
FontId = 1U,
FillId = 2U,
BorderId = 1U,
ApplyFont = true,
ApplyBorder = true,
Alignment = new Alignment()
{
Vertical = VerticalAlignmentValues.Center,
Horizontal = HorizontalAlignmentValues.Center,
WrapText = true
}
};
cellFormats.Append(cellFormatEmpty);
cellFormats.Append(cellFormatDefault);
cellFormats.Append(cellFormatTitle);
sp.Stylesheet.Append(fonts);
sp.Stylesheet.Append(fills);
sp.Stylesheet.Append(borders);
sp.Stylesheet.Append(cellFormats);
}
public void CreateDocument()
{
spreadsheetDocument = SpreadsheetDocument.Create(tempFileName,
SpreadsheetDocumentType.Workbook);
WorkbookPart workbookpart = spreadsheetDocument.AddWorkbookPart();
workbookpart.Workbook = new Workbook();
CreateStyles(workbookpart);
shareStringPart = spreadsheetDocument.WorkbookPart!
.GetPartsOfType<SharedStringTablePart>()
.Any()
? spreadsheetDocument.WorkbookPart
.GetPartsOfType<SharedStringTablePart>()
.First()
: spreadsheetDocument.WorkbookPart
.AddNewPart<SharedStringTablePart>();
if (shareStringPart.SharedStringTable == null)
{
shareStringPart.SharedStringTable = new SharedStringTable();
}
WorksheetPart worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
worksheetPart.Worksheet = new Worksheet(new SheetData());
Sheets sheets = spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets());
Sheet sheet = new()
{
Id = spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
SheetId = 1,
Name = "Лист"
};
sheets.Append(sheet);
worksheet = worksheetPart.Worksheet;
}
public void InsertCellInWorksheet(ExcelCellData cellData)
{
if (worksheet == null || shareStringPart == null)
{
return;
}
var sheetData = worksheet.GetFirstChild<SheetData>();
if (sheetData == null)
{
return;
}
Row? row = sheetData.Elements<Row>()
.Where(r => r.RowIndex! == cellData.RowIndex)
.FirstOrDefault();
if (row == null)
{
row = new Row() { RowIndex = cellData.RowIndex };
sheetData.Append(row);
}
Cell? cell = row.Elements<Cell>()
.Where(c => c.CellReference!.Value == cellData.CellReference)
.FirstOrDefault();
if (cell == null)
{
Cell? refCell = null;
foreach (Cell rowCell in row.Elements<Cell>())
{
if (string.Compare(rowCell.CellReference!.Value, cellData.CellReference, true) > 0)
{
refCell = rowCell;
break;
}
}
var newCell = new Cell()
{
CellReference = cellData.CellReference
};
row.InsertBefore(newCell, refCell);
cell = newCell;
}
shareStringPart.SharedStringTable.AppendChild(new SharedStringItem(new Text(cellData.Text)));
shareStringPart.SharedStringTable.Save();
cell.CellValue = new CellValue((shareStringPart.SharedStringTable.Elements<SharedStringItem>().Count() - 1).ToString());
cell.DataType = new EnumValue<CellValues>(CellValues.SharedString);
cell.StyleIndex = cellData.StyleIndex;
}
private void MergeCells(ExcelMergeParameters excelParams)
{
if (worksheet == null)
{
return;
}
MergeCells mergeCells;
if (worksheet.Elements<MergeCells>().Any())
{
mergeCells = worksheet.Elements<MergeCells>().First();
}
else
{
mergeCells = new MergeCells();
if (worksheet.Elements<CustomSheetView>().Any())
{
worksheet.InsertAfter(mergeCells, worksheet.Elements<CustomSheetView>().First());
}
else
{
worksheet.InsertAfter(mergeCells, worksheet.Elements<SheetData>().First());
}
}
var mergeCell = new MergeCell()
{
Reference = new StringValue(excelParams.Merge)
};
mergeCells.Append(mergeCell);
}
private void Save()
{
if (spreadsheetDocument == null)
{
return;
}
spreadsheetDocument.WorkbookPart!.Workbook.Save();
spreadsheetDocument.Dispose();
}
public byte[] GetFile()
{
Save();
byte[] file = File.ReadAllBytes(tempFileName);
File.Delete(tempFileName);
return file;
}
public void CreateTitle(string text)
{
MergeCells(new ExcelMergeParameters
{
CellFromName = "A1",
CellToName = "B1"
});
InsertCellInWorksheet(new ExcelCellData
{
ColumnName = "A",
RowIndex = 1,
Text = text,
StyleIndex = 0
});
}
public void CreateLawyersHearingTable(List<ReportLawyerHearingViewModel> data)
{
if (worksheet == null || shareStringPart == null)
{
return;
}
Columns columns = new();
Column columnA = new() { Min = 1, Max = 1, Width = 30, CustomWidth = true };
columns.Append(columnA);
Column columnB = new() { Min = 2, Max = 2, Width = 30, CustomWidth = true };
columns.Append(columnB);
worksheet.InsertAt(columns, 0);
InsertCellInWorksheet(new ExcelCellData
{
ColumnName = "A",
RowIndex = 2,
Text = "Юрист",
StyleIndex = 2
});
InsertCellInWorksheet(new ExcelCellData
{
ColumnName = "B",
RowIndex = 2,
Text = "Слушание",
StyleIndex = 2
});
uint currentRow = 3;
foreach (ReportLawyerHearingViewModel lawyer in data)
{
InsertCellInWorksheet(new ExcelCellData
{
ColumnName = "A",
RowIndex = currentRow,
Text = lawyer.Lawyer,
StyleIndex = 1
});
InsertCellInWorksheet(new ExcelCellData
{
ColumnName = "B",
RowIndex = currentRow,
Text = "",
StyleIndex = 1
});
currentRow++;
foreach (string hearing in lawyer.Hearings)
{
InsertCellInWorksheet(new ExcelCellData
{
ColumnName = "A",
RowIndex = currentRow,
Text = "",
StyleIndex = 1
});
InsertCellInWorksheet(new ExcelCellData
{
ColumnName = "B",
RowIndex = currentRow,
Text = hearing,
StyleIndex = 1
});
currentRow++;
}
}
}
}
}

View File

@ -0,0 +1,357 @@
using CaseAccountingBusinessLogic.OfficePackage;
using CaseAccountingBusinessLogic.OfficePackage.HelperModels;
using CaseAccountingContracts.ViewModels;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
namespace CaseAccountingBusinessLogic.OfficePackage
{
public class ExcelBuilderProvider
{
private readonly string tempFileName = "temp.xlsx";
private SpreadsheetDocument? spreadsheetDocument;
private SharedStringTablePart? shareStringPart;
private Worksheet? worksheet;
private void CreateStyles(WorkbookPart workbookpart)
{
var sp = workbookpart.AddNewPart<WorkbookStylesPart>();
sp.Stylesheet = new Stylesheet();
var fonts = new Fonts() { Count = 2U, KnownFonts = true };
var fontUsual = new Font();
fontUsual.Append(new FontSize() { Val = 12D });
fonts.Append(fontUsual);
var fontTitle = new Font();
fontTitle.Append(new Bold());
fontTitle.Append(new FontSize() { Val = 12D });
fonts.Append(fontTitle);
var fills = new Fills() { Count = 3U };
var fill1 = new Fill();
fill1.Append(new PatternFill()
{
PatternType = PatternValues.None
});
var fill2 = new Fill();
fill2.Append(new PatternFill()
{
PatternType = PatternValues.Gray125
});
var fill3 = new Fill();
fill3.Append(new PatternFill()
{
PatternType = PatternValues.Solid,
ForegroundColor = new()
{
Rgb = "e0e8ff"
}
});
var fill4 = new Fill();
fill1.Append(new PatternFill()
{
PatternType = PatternValues.None
});
fills.Append(fill1);
fills.Append(fill2);
fills.Append(fill3);
fills.Append(fill4);
var borders = new Borders() { Count = 2U };
var borderNoBorder = new Border();
borderNoBorder.Append(new LeftBorder());
borderNoBorder.Append(new RightBorder());
borderNoBorder.Append(new TopBorder());
borderNoBorder.Append(new BottomBorder());
borderNoBorder.Append(new DiagonalBorder());
var borderThin = new Border();
var leftBorder = new LeftBorder() { Style = BorderStyleValues.Thin };
leftBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
var rightBorder = new RightBorder() { Style = BorderStyleValues.Thin };
rightBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
var topBorder = new TopBorder() { Style = BorderStyleValues.Thin };
topBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
var bottomBorder = new BottomBorder() { Style = BorderStyleValues.Thin };
bottomBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
borderThin.Append(leftBorder);
borderThin.Append(rightBorder);
borderThin.Append(topBorder);
borderThin.Append(bottomBorder);
borderThin.Append(new DiagonalBorder());
borders.Append(borderNoBorder);
borders.Append(borderThin);
CellFormats cellFormats = new() { Count = 4U };
CellFormat cellFormatEmpty = new()
{
FontId = 0U,
FillId = 0U,
BorderId = 1U,
ApplyFont = true
};
CellFormat cellFormatDefault = new()
{
FontId = 0U,
FillId = 3U,
BorderId = 1U,
ApplyFont = true
};
CellFormat cellFormatTitle = new()
{
FontId = 1U,
FillId = 2U,
BorderId = 1U,
ApplyFont = true,
ApplyBorder = true,
Alignment = new Alignment()
{
Vertical = VerticalAlignmentValues.Center,
Horizontal = HorizontalAlignmentValues.Center,
WrapText = true
}
};
cellFormats.Append(cellFormatEmpty);
cellFormats.Append(cellFormatDefault);
cellFormats.Append(cellFormatTitle);
sp.Stylesheet.Append(fonts);
sp.Stylesheet.Append(fills);
sp.Stylesheet.Append(borders);
sp.Stylesheet.Append(cellFormats);
}
public void CreateDocument()
{
spreadsheetDocument = SpreadsheetDocument.Create(tempFileName,
SpreadsheetDocumentType.Workbook);
WorkbookPart workbookpart = spreadsheetDocument.AddWorkbookPart();
workbookpart.Workbook = new Workbook();
CreateStyles(workbookpart);
shareStringPart = spreadsheetDocument.WorkbookPart!
.GetPartsOfType<SharedStringTablePart>()
.Any()
? spreadsheetDocument.WorkbookPart
.GetPartsOfType<SharedStringTablePart>()
.First()
: spreadsheetDocument.WorkbookPart
.AddNewPart<SharedStringTablePart>();
if (shareStringPart.SharedStringTable == null)
{
shareStringPart.SharedStringTable = new SharedStringTable();
}
WorksheetPart worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
worksheetPart.Worksheet = new Worksheet(new SheetData());
Sheets sheets = spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets());
Sheet sheet = new()
{
Id = spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
SheetId = 1,
Name = "Лист"
};
sheets.Append(sheet);
worksheet = worksheetPart.Worksheet;
}
public void InsertCellInWorksheet(ExcelCellData cellData)
{
if (worksheet == null || shareStringPart == null)
{
return;
}
var sheetData = worksheet.GetFirstChild<SheetData>();
if (sheetData == null)
{
return;
}
Row? row = sheetData.Elements<Row>()
.Where(r => r.RowIndex! == cellData.RowIndex)
.FirstOrDefault();
if (row == null)
{
row = new Row() { RowIndex = cellData.RowIndex };
sheetData.Append(row);
}
Cell? cell = row.Elements<Cell>()
.Where(c => c.CellReference!.Value == cellData.CellReference)
.FirstOrDefault();
if (cell == null)
{
Cell? refCell = null;
foreach (Cell rowCell in row.Elements<Cell>())
{
if (string.Compare(rowCell.CellReference!.Value, cellData.CellReference, true) > 0)
{
refCell = rowCell;
break;
}
}
var newCell = new Cell()
{
CellReference = cellData.CellReference
};
row.InsertBefore(newCell, refCell);
cell = newCell;
}
shareStringPart.SharedStringTable.AppendChild(new SharedStringItem(new Text(cellData.Text)));
shareStringPart.SharedStringTable.Save();
cell.CellValue = new CellValue((shareStringPart.SharedStringTable.Elements<SharedStringItem>().Count() - 1).ToString());
cell.DataType = new EnumValue<CellValues>(CellValues.SharedString);
cell.StyleIndex = cellData.StyleIndex;
}
private void MergeCells(ExcelMergeParameters excelParams)
{
if (worksheet == null)
{
return;
}
MergeCells mergeCells;
if (worksheet.Elements<MergeCells>().Any())
{
mergeCells = worksheet.Elements<MergeCells>().First();
}
else
{
mergeCells = new MergeCells();
if (worksheet.Elements<CustomSheetView>().Any())
{
worksheet.InsertAfter(mergeCells, worksheet.Elements<CustomSheetView>().First());
}
else
{
worksheet.InsertAfter(mergeCells, worksheet.Elements<SheetData>().First());
}
}
var mergeCell = new MergeCell()
{
Reference = new StringValue(excelParams.Merge)
};
mergeCells.Append(mergeCell);
}
private void Save()
{
if (spreadsheetDocument == null)
{
return;
}
spreadsheetDocument.WorkbookPart!.Workbook.Save();
spreadsheetDocument.Dispose();
}
public byte[] GetFile()
{
Save();
byte[] file = File.ReadAllBytes(tempFileName);
File.Delete(tempFileName);
return file;
}
public void CreateTitle(string text)
{
MergeCells(new ExcelMergeParameters
{
CellFromName = "A1",
CellToName = "B1"
});
InsertCellInWorksheet(new ExcelCellData
{
ColumnName = "A",
RowIndex = 1,
Text = text,
StyleIndex = 0
});
}
public void CreateCaseSpecializationTable(List<ReportCaseSpecializationViewModel> data)
{
if (worksheet == null || shareStringPart == null)
{
return;
}
Columns columns = new();
Column columnA = new() { Min = 1, Max = 1, Width = 30, CustomWidth = true };
columns.Append(columnA);
Column columnB = new() { Min = 2, Max = 2, Width = 30, CustomWidth = true };
columns.Append(columnB);
worksheet.InsertAt(columns, 0);
InsertCellInWorksheet(new ExcelCellData
{
ColumnName = "A",
RowIndex = 2,
Text = "Специализация:",
StyleIndex = 2
});
InsertCellInWorksheet(new ExcelCellData
{
ColumnName = "B",
RowIndex = 2,
Text = "Дела:",
StyleIndex = 2
});
uint currentRow = 3;
foreach (ReportCaseSpecializationViewModel specialization in data)
{
InsertCellInWorksheet(new ExcelCellData
{
ColumnName = "A",
RowIndex = currentRow,
Text = specialization.Specialization,
StyleIndex = 1
});
InsertCellInWorksheet(new ExcelCellData
{
ColumnName = "B",
RowIndex = currentRow,
Text = "",
StyleIndex = 1
});
currentRow++;
foreach (string caseName in specialization.Cases)
{
InsertCellInWorksheet(new ExcelCellData
{
ColumnName = "A",
RowIndex = currentRow,
Text = "",
StyleIndex = 1
});
InsertCellInWorksheet(new ExcelCellData
{
ColumnName = "B",
RowIndex = currentRow,
Text = caseName,
StyleIndex = 1
});
currentRow++;
}
}
}
}
}

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComputersShopBusinessLogic.OfficePackage.HelperEnums
namespace CaseAccountingBusinessLogic.OfficePackage.HelperEnums
{
public enum ExcelStyleInfoType
{

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComputersShopBusinessLogic.OfficePackage.HelperEnums
namespace CaseAccountingBusinessLogic.OfficePackage.HelperEnums
{
public enum PdfParagraphAlignmentType
{

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComputersShopBusinessLogic.OfficePackage.HelperEnums
namespace CaseAccountingBusinessLogic.OfficePackage.HelperEnums
{
public enum WordJustificationType
{

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CaseAccountingBusinessLogic.OfficePackage.HelperModels
{
public class ExcelCellData
{
public string ColumnName { get; set; } = string.Empty;
public uint RowIndex { get; set; }
public string Text { get; set; } = string.Empty;
public string CellReference => $"{ColumnName}{RowIndex}";
public uint StyleIndex { get; set; } = 0;
}
}

View File

@ -1,11 +1,11 @@
using ComputersShopBusinessLogic.OfficePackage.HelperEnums;
using CaseAccountingBusinessLogic.OfficePackage.HelperEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComputersShopBusinessLogic.OfficePackage.HelperModels
namespace CaseAccountingBusinessLogic.OfficePackage.HelperModels
{
public class ExcelCellParameters
{

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComputersShopBusinessLogic.OfficePackage.HelperModels
namespace CaseAccountingBusinessLogic.OfficePackage.HelperModels
{
public class ExcelMergeParameters
{

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CaseAccountingBusinessLogic.OfficePackage.HelperModels
{
public class PdfData<T>
{
public string Title { get; set; } = string.Empty;
public DateTime DateFrom { get; set; }
public DateTime DateTo { get; set; }
public List<T> Records { get; set; } = new();
}
}

View File

@ -1,11 +1,11 @@
using ComputersShopBusinessLogic.OfficePackage.HelperEnums;
using CaseAccountingBusinessLogic.OfficePackage.HelperEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComputersShopBusinessLogic.OfficePackage.HelperModels
namespace CaseAccountingBusinessLogic.OfficePackage.HelperModels
{
public class PdfParagraph
{

View File

@ -1,11 +1,11 @@
using ComputersShopBusinessLogic.OfficePackage.HelperEnums;
using CaseAccountingBusinessLogic.OfficePackage.HelperEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComputersShopBusinessLogic.OfficePackage.HelperModels
namespace CaseAccountingBusinessLogic.OfficePackage.HelperModels
{
public class PdfRowParameters
{

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComputersShopBusinessLogic.OfficePackage.HelperModels
namespace CaseAccountingBusinessLogic.OfficePackage.HelperModels
{
public class WordParagraph
{

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CaseAccountingBusinessLogic.OfficePackage.HelperModels
{
public class WordTableData
{
public List<(string, int)> Columns { get; set; } = new();
public List<List<string>> Rows { get; set; } = new();
}
}

View File

@ -1,11 +1,11 @@
using ComputersShopBusinessLogic.OfficePackage.HelperEnums;
using CaseAccountingBusinessLogic.OfficePackage.HelperEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComputersShopBusinessLogic.OfficePackage.HelperModels
namespace CaseAccountingBusinessLogic.OfficePackage.HelperModels
{
public class WordTextProperties
{

View File

@ -0,0 +1,183 @@
using CaseAccountingBusinessLogic.OfficePackage;
using CaseAccountingBusinessLogic.OfficePackage.HelperEnums;
using CaseAccountingBusinessLogic.OfficePackage.HelperModels;
using CaseAccountingContracts.ViewModels;
using MigraDoc.DocumentObjectModel;
using MigraDoc.DocumentObjectModel.Tables;
using MigraDoc.Rendering;
using PdfSharp.Pdf;
using System.Text;
namespace CaseAccountingBusinessLogic.BusinessLogic.OfficePackage
{
public class PdfBuilderProvider
{
private readonly string tempFileName = "temp.pdf";
private Document? document;
private Section? section;
private Table? table;
private static ParagraphAlignment GetParagraphAlignment(PdfParagraphAlignmentType type)
{
return type switch
{
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
_ => ParagraphAlignment.Justify,
};
}
private void DefineStyles(Document document)
{
var style = document.Styles["Normal"];
style.Font.Name = "Times New Roman";
style.Font.Size = 14;
style = document.Styles.AddStyle("NormalTitle", "Normal");
style.Font.Bold = true;
}
public void CreateDocument()
{
document = new Document();
DefineStyles(document);
section = document.AddSection();
}
public void CreateParagraph(PdfParagraph pdfParagraph)
{
if (section == null)
{
return;
}
var paragraph = section.AddParagraph(pdfParagraph.Text);
paragraph.Format.SpaceAfter = "1cm";
paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
paragraph.Style = pdfParagraph.Style;
}
public void CreateTable(List<string> columns)
{
if (document == null)
{
return;
}
table = document.LastSection.AddTable();
foreach (var elem in columns)
{
table.AddColumn(elem);
}
}
public void CreateRow(PdfRowParameters rowParameters)
{
if (table == null)
{
return;
}
var row = table.AddRow();
for (int i = 0; i < rowParameters.Texts.Count; ++i)
{
row.Cells[i].AddParagraph(rowParameters.Texts[i]);
if (!string.IsNullOrEmpty(rowParameters.Style))
{
row.Cells[i].Style = rowParameters.Style;
}
Unit borderWidth = 0.5;
row.Cells[i].Borders.Left.Width = borderWidth;
row.Cells[i].Borders.Right.Width = borderWidth;
row.Cells[i].Borders.Top.Width = borderWidth;
row.Cells[i].Borders.Bottom.Width = borderWidth;
row.Cells[i].Format.Alignment = GetParagraphAlignment(rowParameters.ParagraphAlignment);
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
}
}
private void Save()
{
// Регистрация провайдера кодировки для кодировки 1252, без этого ошибОчка была
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
var renderer = new PdfDocumentRenderer(true)
{
Document = document
};
renderer.RenderDocument();
renderer.PdfDocument.Save(tempFileName);
}
public byte[] GetFile()
{
Save();
byte[] file = File.ReadAllBytes(tempFileName);
File.Delete(tempFileName);
return file;
}
public byte[] GetHearingLawyerReportFile(PdfData<ReportHearingLawyerViewModel> data)
{
CreateDocument();
CreateParagraph(new PdfParagraph
{
Text = data.Title,
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateParagraph(new PdfParagraph
{
Text = $"за период с {data.DateFrom.ToShortDateString()} " +
$"по {data.DateTo.ToShortDateString()}",
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateTable(new List<string> { "4cm","5cm", "3cm", "3cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Номер слушания", "Дело", "Дата проведения", "Юрист" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var record in data.Records)
{
List<CaseLawyerViewModel> casesAndLawyes = record.CaseLawyers;
int recordHeight = casesAndLawyes.Count + 1;
for (int i = 0; i < recordHeight; i++)
{
List<string> cellsData = new() { "", "", "", "" };
if (i == 0)
{
cellsData[0] = record.Hearing;
CreateRow(new PdfRowParameters
{
Texts = cellsData,
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
continue;
}
int k = i - 1;
if (k < casesAndLawyes.Count)
{
cellsData[1] = casesAndLawyes[k].Case;
cellsData[2] = casesAndLawyes[k].Date.ToString("yyyy-MM-dd");
cellsData[3] = casesAndLawyes[k].Lawyer;
}
CreateRow(new PdfRowParameters
{
Texts = cellsData,
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
}
}
return GetFile();
}
}
}

View File

@ -0,0 +1,174 @@
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
using DocumentFormat.OpenXml;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CaseAccountingContracts.ViewModels;
namespace CaseAccountingBusinessLogic.OfficePackage.HelperModels
{
public class WordBuilderCustomer
{
private readonly string tempFileName = "temp.docx";
private WordprocessingDocument? wordDocument;
private Body? documentBody;
public void CreateDocument()
{
wordDocument = WordprocessingDocument.Create(tempFileName,
WordprocessingDocumentType.Document);
MainDocumentPart mainPart = wordDocument.AddMainDocumentPart();
mainPart.Document = new Document();
documentBody = mainPart.Document.AppendChild(new Body());
}
public void CreateParagraph(string text)
{
if (documentBody == null)
{
return;
}
Paragraph paragraph = new();
Run run = new();
run.AppendChild(new Text
{
Text = text
});
paragraph.AppendChild(run);
documentBody.AppendChild(paragraph);
}
public void CreateTitle(string text)
{
if (documentBody == null)
{
return;
}
Paragraph paragraph = new();
Run run = new();
RunProperties properties = new();
properties.AppendChild(new Bold());
run.AppendChild(properties);
run.AppendChild(new Text
{
Text = text
});
paragraph.AppendChild(run);
documentBody.AppendChild(paragraph);
}
private TableCell CreateTableCell(string text, bool inHead = false, int? cellWidth = null)
{
Run run = new();
TableCell tableCell = new();
TableCellProperties cellProperties = new()
{
TableCellWidth = new()
{
Width = cellWidth.ToString()
},
TableCellMargin = new()
{
LeftMargin = new()
{
Width = "100"
}
}
};
if (inHead)
{
Shading shading = new()
{
Color = "auto",
Fill = "e0e8ff",
Val = ShadingPatternValues.Clear
};
cellProperties.Append(shading);
RunProperties properties = new();
properties.AppendChild(new Bold());
run.AppendChild(properties);
}
run.AppendChild(new Text
{
Text = text
});
Paragraph paragraph = new(run);
tableCell.AppendChild(paragraph);
tableCell.Append(cellProperties);
return tableCell;
}
protected void CreateTable(WordTableData tableData)
{
if (documentBody == null || tableData == null)
{
return;
}
var table = new Table();
TableProperties tableProperties = new(
new TableBorders(
new TopBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 3 },
new BottomBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 3 },
new LeftBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 3 },
new RightBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 3 },
new InsideHorizontalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 3 },
new InsideVerticalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 3 }
)
);
table.AppendChild(tableProperties);
table.Append(new TableRow(tableData.Columns.Select(x => CreateTableCell(x.Item1, true, x.Item2))));
table.Append(tableData.Rows.Select(x => new TableRow(x.Select(y => CreateTableCell(y)))));
documentBody.AppendChild(table);
}
private void Save()
{
if (documentBody == null || wordDocument == null)
{
return;
}
wordDocument.MainDocumentPart!.Document.Save();
wordDocument.Dispose();
}
public byte[] GetFile()
{
Save();
byte[] file = File.ReadAllBytes(tempFileName);
File.Delete(tempFileName);
return file;
}
public void CreateLawyersHearingTable(List<ReportLawyerHearingViewModel> data)
{
List<List<string>> rows = new();
foreach (ReportLawyerHearingViewModel lawyer in data)
{
List<string> lawyerCells = new() { lawyer.Lawyer, "" };
rows.Add(lawyerCells);
List<string> hearingCells;
foreach (string hearing in lawyer.Hearings)
{
hearingCells = new() { "", hearing };
rows.Add(hearingCells);
}
}
WordTableData wordTable = new()
{
Columns = new List<(string, int)>()
{
("Юрист", 3000),
("Слушание", 3000)
},
Rows = rows
};
CreateTable(wordTable);
}
}
}

View File

@ -0,0 +1,170 @@
using CaseAccountingBusinessLogic.OfficePackage.HelperModels;
using CaseAccountingContracts.ViewModels;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
namespace CaseAccountingBusinessLogic.OfficePackage
{
public class WordBuilderProvider
{
private readonly string tempFileName = "temp.docx";
private WordprocessingDocument? wordDocument;
private Body? documentBody;
public void CreateDocument()
{
wordDocument = WordprocessingDocument.Create(tempFileName,
WordprocessingDocumentType.Document);
MainDocumentPart mainPart = wordDocument.AddMainDocumentPart();
mainPart.Document = new Document();
documentBody = mainPart.Document.AppendChild(new Body());
}
public void CreateParagraph(string text)
{
if (documentBody == null)
{
return;
}
Paragraph paragraph = new();
Run run = new();
run.AppendChild(new Text
{
Text = text
});
paragraph.AppendChild(run);
documentBody.AppendChild(paragraph);
}
public void CreateTitle(string text)
{
if (documentBody == null)
{
return;
}
Paragraph paragraph = new();
Run run = new();
RunProperties properties = new();
properties.AppendChild(new Bold());
run.AppendChild(properties);
run.AppendChild(new Text
{
Text = text
});
paragraph.AppendChild(run);
documentBody.AppendChild(paragraph);
}
private TableCell CreateTableCell(string text, bool inHead = false, int? cellWidth = null)
{
Run run = new();
TableCell tableCell = new();
TableCellProperties cellProperties = new()
{
TableCellWidth = new()
{
Width = cellWidth.ToString()
},
TableCellMargin = new()
{
LeftMargin = new()
{
Width = "100"
}
}
};
if (inHead)
{
Shading shading = new()
{
Color = "auto",
Fill = "e0e8ff",
Val = ShadingPatternValues.Clear
};
cellProperties.Append(shading);
RunProperties properties = new();
properties.AppendChild(new Bold());
run.AppendChild(properties);
}
run.AppendChild(new Text
{
Text = text
});
Paragraph paragraph = new(run);
tableCell.AppendChild(paragraph);
tableCell.Append(cellProperties);
return tableCell;
}
protected void CreateTable(WordTableData tableData)
{
if (documentBody == null || tableData == null)
{
return;
}
var table = new Table();
TableProperties tableProperties = new(
new TableBorders(
new TopBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 3 },
new BottomBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 3 },
new LeftBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 3 },
new RightBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 3 },
new InsideHorizontalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 3 },
new InsideVerticalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 3 }
)
);
table.AppendChild(tableProperties);
table.Append(new TableRow(tableData.Columns.Select(x => CreateTableCell(x.Item1, true, x.Item2))));
table.Append(tableData.Rows.Select(x => new TableRow(x.Select(y => CreateTableCell(y)))));
documentBody.AppendChild(table);
}
private void Save()
{
if (documentBody == null || wordDocument == null)
{
return;
}
wordDocument.MainDocumentPart!.Document.Save();
wordDocument.Dispose();
}
public byte[] GetFile()
{
Save();
byte[] file = File.ReadAllBytes(tempFileName);
File.Delete(tempFileName);
return file;
}
public void CreateCaseSpecializationTable(List<ReportCaseSpecializationViewModel> data)
{
List<List<string>> rows = new();
foreach (ReportCaseSpecializationViewModel specializationl in data)
{
List<string> specializationlCells = new() { specializationl.Specialization, "" };
rows.Add(specializationlCells);
List<string> caseCells;
foreach (string caseString in specializationl.Cases)
{
caseCells = new() { "", caseString };
rows.Add(caseCells);
}
}
WordTableData wordTable = new()
{
Columns = new List<(string, int)>()
{
("Специализация", 3000),
("Дела", 3000)
},
Rows = rows
};
CreateTable(wordTable);
}
}
}

View File

@ -0,0 +1,15 @@
using CaseAccountingContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CaseAccountingContracts.BindingModels
{
public class CaseSpecializationListBindingModel
{
public string FileType { get; set; } = string.Empty;
public List<CaseViewModel> Cases { get; set; } = new();
}
}

View File

@ -1,4 +1,6 @@
using CaseAccountingDataModels.Models;
using CaseAccountingContracts.ViewModels;
using CaseAccountingDataModels.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
@ -20,5 +22,20 @@ namespace CaseAccountingContracts.BindingModels
public int Id { get; set; }
public Dictionary<int, ICaseModel> Cases { get; set; } = new();
public List<CaseViewModel> CaseViewModels { get; set; } = new();
public Dictionary<int, IContractModel> Contracts { get; set; } = new();
public List<ContractViewModel> ContractViewModels { get; set; } = new();
public DealBindingModel() { }
[JsonConstructor]
public DealBindingModel(Dictionary<int, CaseViewModel> Cases, Dictionary<int, ContractViewModel> Contracts)
{
this.Cases = Cases.ToDictionary(x => x.Key, x => (ICaseModel)x.Value);
this.Contracts = Contracts.ToDictionary(x => x.Key, x => (IContractModel)x.Value);
}
}
}

View File

@ -1,7 +1,10 @@
using CaseAccountingDataModels.Models;
using CaseAccountingContracts.ViewModels;
using CaseAccountingDataModels.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
@ -17,12 +20,28 @@ namespace CaseAccountingContracts.BindingModels
public int Experience { get; set; }
public int SpecializationId { get; set; }
public int? SpecializationId { get; set; }
public int UserId { get; set; }
public int Id { get; set; }
public Dictionary<int, ICaseModel> Cases { get; set; } = new();
public List<CaseViewModel> CaseViewModels { get; set; } = new();
public Dictionary<int, IContractModel> Contracts { get; set; } = new();
public List<ContractViewModel> ContractViewModels { get; set; } = new();
public LawyerBindingModel() { }
[JsonConstructor]
public LawyerBindingModel(Dictionary<int, ContractViewModel> Contracts, Dictionary<int, CaseViewModel> Cases)
{
this.Contracts = Contracts.ToDictionary(x => x.Key, x => (IContractModel)x.Value);
this.Cases = Cases.ToDictionary(x => x.Key, x => (ICaseModel)x.Value);
}
}
}

View File

@ -0,0 +1,15 @@
using CaseAccountingContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CaseAccountingContracts.BindingModels
{
public class LawyerHearingListBindingModel
{
public string FileType { get; set; } = string.Empty;
public List<LawyerViewModel> Lawyers { get; set; } = new();
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CaseAccountingContracts.BindingModels
{
public class MailConfigBindingModel
{
public string MailLogin { get; set; } = string.Empty;
public string MailPassword { get; set; } = string.Empty;
public string SmtpClientHost { get; set; } = string.Empty;
public int SmtpClientPort { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CaseAccountingContracts.BindingModels
{
public class MailSendInfoBindingModel
{
public string MailAddress { get; set; } = string.Empty;
public string Subject { get; set; } = string.Empty;
public string Text { get; set; } = string.Empty;
public byte[] File { get; set; } = Array.Empty<byte>();
}
}

View File

@ -9,12 +9,9 @@ namespace CaseAccountingContracts.BindingModels
{
public class ReportBindingModel
{
public string FileName { get; set; } = string.Empty;
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
public string UserEmail { get; set; } = string.Empty;
public DateTime DateFrom { get; set; }
public DateTime DateTo { get; set; }
public int? UserId { get; set; }
}
}

View File

@ -16,5 +16,6 @@ namespace CaseAccountingContracts.BusinessLogicContracts
bool Create(CaseBindingModel model);
bool Update(CaseBindingModel model);
bool Delete(CaseBindingModel model);
List<SpecializationCasesViewModel> GetSpecializationCases();
}
}

View File

@ -10,10 +10,12 @@ namespace CaseAccountingContracts.BusinessLogicContracts
{
public interface IReportCustomerLogic
{
List<ReportLawyerHearingViewModel> GetLawyerHearing(List<LawyerViewModel> models);
List<ReportLawyerHearingViewModel> GetLawyersHearing(List<LawyerViewModel> models);
List<ReportHearingSpecializationViewModel> GetHearingSpecialization(ReportBindingModel model);
byte[] SaveListFile(LawyerHearingListBindingModel model);
void SaveLawyerHearingToWordFile(ReportBindingModel model);
void SaveLawyerHearingToExcelFile(ReportBindingModel model);

View File

@ -14,10 +14,8 @@ namespace CaseAccountingContracts.BusinessLogicContracts
List<ReportHearingLawyerViewModel> GetHearingLawyer(ReportBindingModel model);
void SaveCaseSpecializationToWordFile(ReportBindingModel model);
byte[] SaveListFile(CaseSpecializationListBindingModel model);
void SaveCaseSpecializationToExcelFile(ReportBindingModel model);
void SaveHearingLawyerToPdfFile(ReportBindingModel model);
void SendByMailStatusReport(ReportBindingModel reportModel);
}
}

View File

@ -6,6 +6,10 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CaseAccountingDataModels\CaseAccountingDataModels.csproj" />
</ItemGroup>

View File

@ -17,5 +17,8 @@ namespace CaseAccountingContracts.StoragesContracts
CaseViewModel? Insert(CaseBindingModel model);
CaseViewModel? Update(CaseBindingModel model);
CaseViewModel? Delete(CaseBindingModel model);
List<HearingViewModel> GetCaseHearings(CaseSearchModel model);
List<SpecializationCasesViewModel>? GetSpecializationCases();
}
}

View File

@ -17,5 +17,8 @@ namespace CaseAccountingContracts.StoragesContracts
LawyerViewModel? Insert(LawyerBindingModel model);
LawyerViewModel? Update(LawyerBindingModel model);
LawyerViewModel? Delete(LawyerBindingModel model);
List<CaseViewModel> GetLawyerCases(LawyerSearchModel model);
List<LawyerViewModel> GetLawyerMTM(int caseId);
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CaseAccountingContracts.ViewModels
{
public class CaseLawyerViewModel
{
public string Case { get; set; } = string.Empty;
public DateTime Date { get; set; }
public string Lawyer { get; set; } = string.Empty;
}
}

View File

@ -18,11 +18,13 @@ namespace CaseAccountingContracts.ViewModels
public string Patronymic { get; set; } = string.Empty;
[DisplayName("Опыт работы")]
public int Experience { get; set; }
public int SpecializationId { get; set; }
public int? SpecializationId { get; set; }
[DisplayName("Специализация")]
public string Specialization { get; set; } = string.Empty;
public int UserId { get; set; }
public int Id { get; set; }
public Dictionary<int, IContractModel> Contracts { get; set; } = new();
public Dictionary<int, ICaseModel> Cases { get; set; } = new();
}
}

View File

@ -8,10 +8,7 @@ namespace CaseAccountingContracts.ViewModels
{
public class ReportCaseSpecializationViewModel
{
public string CaseName { get; set; } = string.Empty;
public string Applicant { get; set; } = string.Empty;
public string Defendant { get; set; } = string.Empty;
public DateTime Date { get; set; }
public string Specialization { get; set; } = string.Empty;
public List<string> Cases { get; set; } = new();
}
}

View File

@ -8,8 +8,7 @@ namespace CaseAccountingContracts.ViewModels
{
public class ReportHearingLawyerViewModel
{
public string Information { get; set; } = string.Empty;
public DateTime Date { get; set; }
public List<(string Surname, string Name, string Patronymic)> Lawyers { get; set; } = new();
public string Hearing { get; set; } = string.Empty;
public List<CaseLawyerViewModel> CaseLawyers { get; set; } = new();
}
}

View File

@ -8,12 +8,7 @@ namespace CaseAccountingContracts.ViewModels
{
public class ReportLawyerHearingViewModel
{
public string Name { get; set; } = string.Empty;
public string Surname { get; set; } = string.Empty;
public string Patronymic { get; set; } = string.Empty;
public List<(DateTime Date, string Information)> Hearings { get; set; } = new();
public string Lawyer { get; set; } = string.Empty;
public List<string> Hearings { get; set; } = new();
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CaseAccountingContracts.ViewModels
{
public class SpecializationCasesViewModel
{
public int Count { get; set; }
public string Name { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,63 @@
using CaseAccountingContracts.ViewModels;
using Newtonsoft.Json;
using System.Net.Http.Headers;
using System.Text;
namespace CaseAccountingCustomerView
{
public static class APIUser
{
private static readonly HttpClient _client = new();
public static UserViewModel? User { get; set; } = null;
public static void Connect(IConfiguration configuration)
{
_client.BaseAddress = new Uri(configuration["IPAddress"]);
_client.DefaultRequestHeaders.Accept.Clear();
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
}
public static T? GetRequest<T>(string requestUrl)
{
var response = _client.GetAsync(requestUrl);
var result = response.Result.Content.ReadAsStringAsync().Result;
if (response.Result.IsSuccessStatusCode)
{
return JsonConvert.DeserializeObject<T>(result);
}
else
{
throw new Exception(result);
}
}
public static void PostRequest<T>(string requestUrl, T model)
{
var json = JsonConvert.SerializeObject(model);
var data = new StringContent(json, Encoding.UTF8, "application/json");
var response = _client.PostAsync(requestUrl, data);
var result = response.Result.Content.ReadAsStringAsync().Result;
if (!response.Result.IsSuccessStatusCode)
{
throw new Exception(result);
}
}
public static O? PostRequestWithResult<I, O>(string requestUrl, I model)
{
var json = JsonConvert.SerializeObject(model);
var data = new StringContent(json, Encoding.UTF8, "application/json");
var response = _client.PostAsync(requestUrl, data);
var result = response.Result.Content.ReadAsStringAsync().Result;
if (response.Result.IsSuccessStatusCode)
{
var temp = JsonConvert.DeserializeObject<O>(result);
return temp;
}
else
{
return default;
}
}
}
}

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CaseAccountingContracts\CaseAccountingContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,83 @@
using CaseAccountingContracts.BindingModels;
using CaseAccountingContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace CaseAccountingCustomerView.Controllers
{
public class Contracts : Controller
{
public IActionResult Create()
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
return View();
}
[HttpPost]
public void Create([FromBody] ContractBindingModel contractModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
contractModel.UserId = APIUser.User.Id;
APIUser.PostRequest("api/contract/create", contractModel);
Response.Redirect("/Home/Contracts");
}
public IActionResult Update(int id)
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Contract = APIUser.GetRequest<ContractViewModel>($"api/contract/get?id={id}");
return View();
}
[HttpPost]
public void Update([FromBody] ContractBindingModel contractModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
contractModel.UserId = APIUser.User.Id;
APIUser.PostRequest("api/contract/update", contractModel);
Response.Redirect("/Home/Contracts");
}
[HttpPost]
public void Delete(int id)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
APIUser.PostRequest($"api/contract/delete", new ContractBindingModel() { Id = id });
Response.Redirect("/Home/Contracts");
}
public List<ContractViewModel> GetAllByUser()
{
if (APIUser.User == null)
{
return new();
}
List<ContractViewModel>? contracts = APIUser.GetRequest<List<ContractViewModel>>($"api/contract/getallbyuser?userId={APIUser.User.Id}");
return contracts ?? new();
}
public ContractViewModel? Get(int id)
{
if (APIUser.User == null)
{
return new();
}
ContractViewModel? contract = APIUser.GetRequest<ContractViewModel>($"api/contract/get?id={id}");
return contract;
}
}
}

View File

@ -0,0 +1,121 @@
using CaseAccountingContracts.BindingModels;
using CaseAccountingContracts.ViewModels;
using CaseAccountingCustomerView.Models;
using CaseAccountingDataModels.Enum;
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
namespace CaseAccountingCustomerView.Controllers
{
public class HomeController : Controller
{
public HomeController() { }
public IActionResult Index()
{
if (APIUser.User == null)
{
return Redirect("~/Home/Login");
}
return View();
}
public IActionResult Login()
{
return View();
}
public IActionResult Registration()
{
return View();
}
[HttpPost]
public void Login(string login, string password)
{
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
{
throw new Exception("Введите логин и пароль");
}
APIUser.User = APIUser.GetRequest<UserViewModel>($"api/user/login?login={login}&password={password}&role={Role.Customer}");
if (APIUser.User == null)
{
throw new Exception("Неверный логин/пароль");
}
Response.Redirect("Index");
}
[HttpPost]
public void Registration(string login, string password)
{
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
{
throw new Exception("Введите логин и пароль");
}
APIUser.PostRequest("api/user/register", new UserBindingModel
{
Login = login,
Password = password,
Role = Role.Customer
});
Response.Redirect("Login");
return;
}
public IActionResult Lawyers( )
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Lawyers = APIUser.GetRequest<List<LawyerViewModel>>
($"api/lawyer/getallbyuser?userId={APIUser.User.Id}");
return View();
}
public IActionResult Specializations()
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Specializations = APIUser.GetRequest<List<SpecializationViewModel>>
($"api/specialization/getallbyuser?userId={APIUser.User.Id}");
return View();
}
public IActionResult Contracts()
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Contracts = APIUser.GetRequest<List<ContractViewModel>>
($"api/contract/getallbyuser?userId={APIUser.User.Id}");
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
[HttpPost]
public int[]? HearingLawyerList([FromBody] LawyerHearingListBindingModel listModel)
{
if (APIUser.User == null)
{
return Array.Empty<int>();
}
byte[]? file = APIUser.PostRequestWithResult<LawyerHearingListBindingModel, byte[]>
("api/reportcustomer/lawyerhearinglist", listModel);
return file!.Select(b => (int)b).ToArray();
}
public IActionResult HearingLawyerList()
{
return View();
}
}
}

View File

@ -0,0 +1,148 @@
using CaseAccountingContracts.BindingModels;
using CaseAccountingContracts.ViewModels;
using CaseAccountingDataModels.Models;
using Microsoft.AspNetCore.Mvc;
namespace CaseAccountingCustomerView.Controllers
{
public class Lawyers : Controller
{
public IActionResult Create()
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
return View();
}
[HttpPost]
public void Create([FromBody] LawyerBindingModel lawyerModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
lawyerModel.UserId = APIUser.User.Id;
lawyerModel.SpecializationId = null;
var dict = new Dictionary<int, IContractModel>();
foreach (var element in lawyerModel.ContractViewModels)
{
var contract = APIUser.GetRequest<ContractViewModel>($"api/contract/get?id={element.Id}");
dict.Add(element.Id, contract);
}
lawyerModel.Contracts = dict;
APIUser.PostRequest("api/lawyer/create", lawyerModel);
Response.Redirect("/Home/Lawyers");
}
public IActionResult Update(int id)
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Lawyer = APIUser.GetRequest<LawyerViewModel>($"api/lawyer/get?id={id}");
return View();
}
[HttpPost]
public void Update([FromBody] LawyerBindingModel lawyerModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
lawyerModel.UserId = APIUser.User.Id;
var dict = new Dictionary<int, ICaseModel>();
foreach (var element in lawyerModel.CaseViewModels)
{
var _case = APIUser.GetRequest<CaseViewModel>($"api/case/get?id={element.Id}");
dict.Add(element.Id, _case);
}
lawyerModel.Cases = dict;
var dictContr = new Dictionary<int, IContractModel>();
foreach (var element in lawyerModel.ContractViewModels)
{
var contract = APIUser.GetRequest<ContractViewModel>($"api/contract/get?id={element.Id}");
dictContr.Add(element.Id, contract);
}
lawyerModel.Contracts = dictContr;
APIUser.PostRequest("api/lawyer/update", lawyerModel);
Response.Redirect("/Home/Lawyers");
}
[HttpPost]
public void Delete(int id)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
APIUser.PostRequest($"api/lawyer/delete", new LawyerBindingModel() { Id = id });
Response.Redirect("/Home/Lawyers");
}
public List<LawyerViewModel> GetAllByUser()
{
if (APIUser.User == null)
{
return new();
}
List<LawyerViewModel> ? lawyers = APIUser.GetRequest<List<LawyerViewModel>>($"api/lawyer/getallbyuser?userId={APIUser.User.Id}");
return lawyers ?? new();
}
public LawyerViewModel? Get(int id)
{
if (APIUser.User == null)
{
return new();
}
LawyerViewModel? lawyer = APIUser.GetRequest<LawyerViewModel>($"api/lawyer/get?id={id}");
return lawyer;
}
public IActionResult Bind(int id)
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Lawyer = APIUser.GetRequest<LawyerViewModel>($"api/lawyer/get?id={id}");
return View();
}
[HttpPost]
public void Bind([FromBody] LawyerBindingModel lawyerModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
APIUser.PostRequest("api/lawyer/update", lawyerModel);
}
public List<LawyerViewModel> GetAllByUserAndSpecialization(int specialization)
{
if (APIUser.User == null)
{
return new();
}
List<LawyerViewModel>? lawyers = APIUser.GetRequest<List<LawyerViewModel>>($"api/lawyer/getallbyuserandspecialization?userId={APIUser.User.Id}&specialization={specialization}");
return lawyers ?? new();
}
public List<CaseViewModel> GetAllCases()
{
if (APIUser.User == null)
{
return new();
}
List<CaseViewModel>? _case = APIUser.GetRequest<List<CaseViewModel>>("api/lawyer/GetAllCases");
return _case ?? new();
}
}
}

View File

@ -0,0 +1,102 @@
using CaseAccountingContracts.BindingModels;
using CaseAccountingContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace CaseAccountingCustomerView.Controllers
{
public class Specializations : Controller
{
public IActionResult Create()
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
return View();
}
[HttpPost]
public void Create([FromBody] SpecializationBindingModel specializationModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
specializationModel.UserId = APIUser.User.Id;
APIUser.PostRequest("api/specialization/create", specializationModel);
Response.Redirect("/Home/Specializations");
}
public IActionResult Update(int id)
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Specialization = APIUser.GetRequest<SpecializationViewModel>($"api/specialization/get?id={id}");
return View();
}
[HttpPost]
public void Update([FromBody] SpecializationBindingModel specializationModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
specializationModel.UserId = APIUser.User.Id;
APIUser.PostRequest("api/specialization/update", specializationModel);
Response.Redirect("/Home/Specializations");
}
[HttpPost]
public void Delete(int id)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
APIUser.PostRequest($"api/specialization/delete", new SpecializationBindingModel() { Id = id });
Response.Redirect("/Home/Specializations");
}
public List<SpecializationViewModel> GetAllByUser()
{
if (APIUser.User == null)
{
return new();
}
List<SpecializationViewModel>? specializations = APIUser.GetRequest<List<SpecializationViewModel>>($"api/specialization/getallbyuser?userId={APIUser.User.Id}");
return specializations ?? new();
}
public SpecializationViewModel? Get(int id)
{
if (APIUser.User == null)
{
return new();
}
SpecializationViewModel? specialization = APIUser.GetRequest<SpecializationViewModel>($"api/specialization/get?id={id}");
return specialization;
}
public IActionResult AddLawyer(int id)
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.SpecializationId = id;
return View();
}
[HttpPost]
public void AddLawyer([FromBody] LawyerBindingModel lawyerModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
APIUser.PostRequest("api/lawyer/update", lawyerModel);
}
}
}

View File

@ -0,0 +1,9 @@
namespace CaseAccountingCustomerView.Models
{
public class ErrorViewModel
{
public string? RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
}
}

View File

@ -0,0 +1,31 @@
using CaseAccountingCustomerView;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllersWithViews();
var app = builder.Build();
APIUser.Connect(builder.Configuration);
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();

View File

@ -0,0 +1,28 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:5198",
"sslPort": 44306
}
},
"profiles": {
"CaseAccountingCustomerView": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7019;http://localhost:5019",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,24 @@
@{
ViewData["Title"] = "Контракт";
}
<h4 class="fw-bold">Добавление контракта</h4>
<div id="error-div-shell" class="error-div-shell mb-2">
<div>
<p id="error-p" class="error-p"></p>
</div>
</div>
<p class="mb-0">Услуга:</p>
<input type="text" id="service-input" name="service" class="form-control mb-3" />
<p class="mb-0">Цена:</p>
<input type="number" id="coast-input" name="coast" class="form-control mb-3" step="0.01"/>
<p class="mb-0">Дата:</p>
<input type="date" id="date-input" name="date" class="form-control mb-3" />
<button id="create-button" type="button" class="button-primary text-button">
Создать
</button>
<script src="~/js/Contracts/contract-create.js" asp-append-version="true"></script>

View File

@ -0,0 +1,34 @@
@using CaseAccountingContracts.ViewModels
@{
ViewData["Title"] = "Контракт";
}
@{
<h4 class="fw-bold" id="contr-id" data-id="@ViewBag.Contract.Id">Изменение данных контракта</h4>
if (ViewBag.Contract == null)
{
<h3 class="display-4">Войдите в аккаунт</h3>
return;
}
<div id="error-div-shell" class="error-div-shell mb-2">
<div>
<p id="error-p" class="error-p"></p>
</div>
</div>
<p class="mb-0">Услуга:</p>
<input value="@ViewBag.Contract.Service" type="text" id="service-input" name="service" class="form-control mb-3" />
<p class="mb-0">Цена:</p>
<input value="@ViewBag.Contract.Coast" type="number" id="coast-input" name="coast" class="form-control mb-3" step="0.01"/>
<p class="mb-0">Дата:</p>
<input value="@ViewBag.Contract.Date.ToString("yyyy-MM-dd")" type="date" id="date-input" name="date" class="form-control mb-3" />
<button id="update-button" type="button" class="button-primary text-button">
Сохранить изменения
</button>
}
<script src="~/js/Contracts/contract-update.js" asp-append-version="true"></script>

View File

@ -0,0 +1,72 @@
@using CaseAccountingContracts.ViewModels
@{
ViewData["Title"] = "Контракты";
}
<div class="text-center">
<h1 class="display-4">Контракты</h1>
</div>
<div class="text-center">
@{
if (ViewBag.Contracts == null)
{
<h3 class="display-4">Войдите в аккаунт</h3>
return;
}
<div>
<a class="btn btn-secondary" asp-controller="Contracts" asp-action="Create">Добавить контракт</a>
</div>
<div class="d-flex mb-2 gap-1">
<a href="/Home/Contracts" id="go-button" class="button-primary text-button">
Перейти
</a>
</div>
<table class="table">
<thead>
<tr>
<th>
Услуга
</th>
<th>
Цена
</th>
<th>
Дата
</th>
<th>
Изменить запись
</th>
<th>
Удалить запись
</th>
</tr>
</thead>
<tbody>
@foreach (var item in ViewBag.Contracts)
{
<tr class="d-table-row">
<td>
@item.Service
</td>
<td>
@item.Coast
</td>
<td>
@item.Date
</td>
<td>
<a id="update-button-@item.Id" class="btn btn-secondary" asp-controller="Contracts" asp-action="Update" asp-route-id="@item.Id">Изменить</a>
</td>
<td>
<a id="remove-button-@item.Id" class="btn btn-secondary remove-btn" data-id="@item.Id">Удалить</a>
</td>
</tr>
}
</tbody>
</table>
}
</div>
<script src="~/js/Contracts/contracts.js" asp-append-version="true"></script>

View File

@ -0,0 +1,44 @@
@{
ViewData["Title"] = "Список слушаний по юристам";
}
<h4 class="fw-bold">Список слушаний по юристам</h4>
<div id="error-div-shell" class="error-div-shell mb-2">
<div>
<p id="error-p" class="error-p"></p>
</div>
</div>
<select id="file-type">
<option>docx</option>
<option>xlsx</option>
</select>
<button id="create-button" type="button" class="button-primary text-button">
Показать итоговый вариант
</button>
<button id="save-button" type="button" class="button-primary text-button">
Сохранить результат
</button>
<div>
<div class="scrollable-table">
<table class="table table-bordered">
<thead class="thead-light">
<tr>
<th>Имя</th>
<th>Фамилия</th>
<th>Отчество</th>
<th>Опыт работы</th>
<th>Специализация</th>
</tr>
</thead>
<tbody id="scrollable-table__tbody">
</tbody>
</table>
</div>
</div>
<script src="~/js/Report/reportlist.js" asp-append-version="true"></script>

View File

@ -0,0 +1,7 @@
@{
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<h1>Добро пожаловать в курсовой проект CaseAccounting</h1>
</div>

View File

@ -0,0 +1,70 @@
@using CaseAccountingContracts.ViewModels
@{
ViewData["Title"] = "Юристы";
}
<div class="text-center">
<h1 class="display-4">Юристы</h1>
</div>
<div class="text-center">
@{
if (ViewBag.Lawyers == null)
{
<h3 class="display-4">Войдите в аккаунт</h3>
return;
}
<div>
<a class="btn btn-secondary" asp-controller="Lawyers" asp-action="Create">Добавить юриста</a>
</div>
<table class="table">
<thead>
<tr>
<th>
Имя Фамилия Отчество
</th>
<th>
Опыт работы
</th>
<th>
Название специализации
</th>
<th>
Изменить запись
</th>
<th>
Удалить запись
</th>
</tr>
</thead>
<tbody>
@foreach (var item in ViewBag.Lawyers)
{
<tr class="d-table-row">
<td>
@item.Name @item.Surname @item.Patronymic
</td>
<td>
@item.Experience
</td>
<td>
@item.Specialization
</td>
<td>
<a id="update-button-@item.Id" class="btn btn-secondary" asp-controller="Lawyers" asp-action="Bind" asp-route-id="@item.Id">Привязка</a>
</td>
<td>
<a id="update-button-@item.Id" class="btn btn-secondary" asp-controller="Lawyers" asp-action="Update" asp-route-id="@item.Id">Изменить</a>
</td>
<td>
<a id="remove-button-@item.Id" class="btn btn-secondary remove-btn" data-id="@item.Id">Удалить</a>
</td>
</tr>
}
</tbody>
</table>
}
</div>
<script src="~/js/Lawyers/lawyers.js" asp-append-version="true"></script>

View File

@ -0,0 +1,27 @@
@{
ViewData["Title"] = "Вход";
}
<div class="text-center">
<h2 class="display-4">Вход в приложение</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Логин:</div>
<div class="col-8"><input type="text" name="login" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="password" name="password" /></div>
</div>
<div class="row">
<div class="col-8">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Registration">
Нет аккаунта?
</a>
</div>
<div class="col-4">
<input type="submit" value="Войти" class="btn btn-primary" />
</div>
</div>
</form>

View File

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

View File

@ -0,0 +1,27 @@
@{
ViewData["Title"] = "Регистрация";
}
<div class="text-center">
<h2 class="display-4">Регистрация</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Логин (эл.почта):</div>
<div class="col-8"><input type="email" name="login" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="password" name="password" /></div>
</div>
<div class="row">
<div class="col-8">
<a class="nav-link text-primary" asp-area="" asp-controller="Home" asp-action="Login">
Есть аккаунт?
</a>
</div>
<div class="col-4">
<input type="submit" value="Регистрация" class="btn btn-primary" />
</div>
</div>
</form>

View File

@ -0,0 +1,63 @@
@using CaseAccountingContracts.ViewModels
@{
ViewData["Title"] = "Специализации";
}
<div class="text-center">
<h1 class="display-4">Специализации</h1>
</div>
<div class="text-center">
@{
if (ViewBag.Specializations == null)
{
<h3 class="display-4">Войдите в аккаунт</h3>
return;
}
<div>
<a class="btn btn-secondary" asp-controller="Specializations" asp-action="Create">Добавить специализацию</a>
</div>
<div class="d-flex mb-2 gap-1">
<a href="/Home/Specializations" id="go-button" class="button-primary text-button">
Перейти
</a>
</div>
<table class="table">
<thead>
<tr>
<th>
Название
</th>
<th>
Изменить запись
</th>
<th>
Удалить запись
</th>
</tr>
</thead>
<tbody>
@foreach (var item in ViewBag.Specializations)
{
<tr class="d-table-row">
<td>
@item.Name
</td>
<td>
<a id="add-lawyer-button-@item.Id" class="btn btn-secondary" asp-controller="Specializations" asp-action="AddLawyer" asp-route-id="@item.Id">Назначить специализацию для юриста</a>
</td>
<td>
<a id="update-button-@item.Id" class="btn btn-secondary" asp-controller="Specializations" asp-action="Update" asp-route-id="@item.Id">Изменить</a>
</td>
<td>
<a id="remove-button-@item.Id" class="btn btn-secondary remove-btn" data-id="@item.Id">Удалить</a>
</td>
</tr>
}
</tbody>
</table>
}
</div>
<script src="~/js/Specializations/specializations.js" asp-append-version="true"></script>

View File

@ -0,0 +1,35 @@
@{
ViewData["Title"] = "Юрист";
}
@{
<h4 id="lawyer-data" class="fw-bold" data-id="@ViewBag.Lawyer.Id">Привязка специализации к юристу</h4>
<div id="error-div-shell" class="error-div-shell mb-2">
<div>
<p id="error-p" class="error-p"></p>
</div>
</div>
<p class="mb-0">Название:</p>
<input type="text" readonly value="@ViewBag.Lawyer.Name" id="name-input" name="name" class="form-control mb-3" />
<button id="create-button" type="button" class="button-primary text-button">
Сохранить привязку
</button>
<div>
<div class="scrollable-table">
<table class="table table-bordered">
<thead class="thead-light">
<tr>
<th>Название дела:</th>
</tr>
</thead>
<tbody id="scrollable-table__tbody">
</tbody>
</table>
</div>
</div>
}
<script src="~/js/Lawyers/lawyer-bind.js" asp-append-version="true"></script>

View File

@ -0,0 +1,42 @@
@{
ViewData["Title"] = "Юрист";
}
<h4 class="fw-bold">Добавление юриста</h4>
<div id="error-div-shell" class="error-div-shell mb-2">
<div>
<p id="error-p" class="error-p"></p>
</div>
</div>
<p class="mb-0">Имя:</p>
<input type="text" id="name-input" name="name" class="form-control mb-3" />
<p class="mb-0">Фамилия:</p>
<input type="text" id="surname-input" name="surname" class="form-control mb-3" />
<p class="mb-0">Отчество:</p>
<input type="text" id="patronymic-input" name="patronymic" class="form-control mb-3" />
<p class="mb-0">Опыт работы:</p>
<input type="number" id="experience-input" name="experience" class="form-control mb-3" />
<div>
<div class="scrollable-table">
<table class="table table-bordered">
<thead class="thead-light">
<tr>
<th>Услуга</th>
<th>Цена</th>
<th>Дата</th>
</tr>
</thead>
<tbody id="scrollable-table__tbody">
</tbody>
</table>
</div>
</div>
<button id="create-button" type="button" class="button-primary text-button">
Создать
</button>
<script src="~/js/Lawyers/lawyer-create.js" asp-append-version="true"></script>

View File

@ -0,0 +1,52 @@
@using CaseAccountingContracts.ViewModels
@{
ViewData["Title"] = "Юрист";
}
@{
<h4 class="fw-bold" id="lawyer-id" data-id="@ViewBag.Lawyer.Id">Изменение данных юриста</h4>
if (ViewBag.Lawyer == null)
{
<h3 class="display-4">Войдите в аккаунт</h3>
return;
}
<div id="error-div-shell" class="error-div-shell mb-2">
<div>
<p id="error-p" class="error-p"></p>
</div>
</div>
<p class="mb-0">Имя:</p>
<input value="@ViewBag.Lawyer.Name" type="text" id="name-input" name="name" class="form-control mb-3" />
<p class="mb-0">Фамилия:</p>
<input value="@ViewBag.Lawyer.Surname" type="text" id="surname-input" name="surname" class="form-control mb-3" />
<p class="mb-0">Отчество:</p>
<input value="@ViewBag.Lawyer.Patronymic" type="text" id="patronymic-input" name="patronymic" class="form-control mb-3" />
<p class="mb-0">Опыт работы:</p>
<input value="@ViewBag.Lawyer.Experience" type="number" id="experience-input" name="experience" class="form-control mb-3" />
<button id="create-button" type="button" class="btn btn-primary text-button">
Сохранить изменения
</button>
<div class="mt-4">
<div class="scrollable-table">
<table class="table table-bordered">
<thead class="thead-light">
<tr>
<th>Услуга</th>
<th>Цена</th>
<th>Дата</th>
</tr>
</thead>
<tbody id="scrollable-table__tbody">
</tbody>
</table>
</div>
</div>
}
<script src="~/js/Lawyers/lawyer-update.js" asp-append-version="true"></script>

View File

@ -0,0 +1,25 @@
@model ErrorViewModel
@{
ViewData["Title"] = "Error";
}
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>
@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}
<h3>Development Mode</h3>
<p>
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>

View File

@ -0,0 +1,58 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - Юридическая фирма «Вас обманут» "Заказчик"</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/CaseAccountingCustomerView.styles.css" asp-append-version="true" />
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container-fluid">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Юридическая фирма «Вас обманут» "Заказчик"</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Contracts">Контракты</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Lawyers">Юристы</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Specializations">Специализации</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="HearingLawyerList">Получить список</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="GetReport">Получить отчёт</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<div class="container">
<main role="main" class="pb-3">
@RenderBody()
</main>
</div>
<footer class="border-top footer text-muted">
<div class="container">
&copy; Юридическая фирма «Вас обманут» "Заказчик" - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
@await RenderSectionAsync("Scripts", required: false)
</body>
</html>

View File

@ -0,0 +1,48 @@
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
for details on configuring this project to bundle and minify static web assets. */
a.navbar-brand {
white-space: normal;
text-align: center;
word-break: break-all;
}
a {
color: #0077cc;
}
.btn-primary {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.border-top {
border-top: 1px solid #e5e5e5;
}
.border-bottom {
border-bottom: 1px solid #e5e5e5;
}
.box-shadow {
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
}
button.accept-policy {
font-size: 1rem;
line-height: inherit;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
white-space: nowrap;
line-height: 60px;
}

View File

@ -0,0 +1,2 @@
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>

View File

@ -0,0 +1,57 @@
@using CaseAccountingContracts.ViewModels
@{
ViewData["Title"] = "Специализация";
}
@{
<h4 class="fw-bold" id="vb-id">Назначение специализации юристу</h4>
if (ViewBag.SpecializationId == null)
{
<h3 class="display-4">Войдите в аккаунт</h3>
return;
}
<div class="row">
<div class="col-md-6">
<label id="specializationLabel" data-id="@ViewBag.SpecializationId" for="specializationInput">Специализация:</label>
<input type="text" id="specializationInput" readonly value="" />
</div>
</div>
<div class="row">
<div class="col-md-6">
<label for="lawyersSelect">Юристы:</label>
<select id="lawyersSelect">
</select>
</div>
</div>
<button id="update-button" type="button" class="button-primary text-button">
Сохранить изменения
</button>
<div class="row">
<div class="col-md-12">
<h3>Итог:</h3>
<table>
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody id="lawyerTable">
<tr id="emptyRow">
<td colspan="3">Выберите юриста!</td>
</tr>
</tbody>
</table>
</div>
</div>
}
<script src="~/js/Specializations/specializations-add-lawyer.js" asp-append-version="true"></script>

View File

@ -0,0 +1,20 @@
@{
ViewData["Title"] = "Специализация";
}
<h4 class="fw-bold">Добавление специализации</h4>
<div id="error-div-shell" class="error-div-shell mb-2">
<div>
<p id="error-p" class="error-p"></p>
</div>
</div>
<p class="mb-0">Название:</p>
<input type="text" id="name-input" name="name" class="form-control mb-3" />
<button id="create-button" type="button" class="button-primary text-button">
Создать
</button>
<script src="~/js/Specializations/specialization-create.js" asp-append-version="true"></script>

View File

@ -0,0 +1,30 @@
@using CaseAccountingContracts.ViewModels
@{
ViewData["Title"] = "Специализация";
}
@{
<h4 class="fw-bold" id="spec-id" data-id="@ViewBag.Specialization.Id">Изменение данных специализации</h4>
if (ViewBag.Specialization == null)
{
<h3 class="display-4">Войдите в аккаунт</h3>
return;
}
<div id="error-div-shell" class="error-div-shell mb-2">
<div>
<p id="error-p" class="error-p"></p>
</div>
</div>
<p class="mb-0">Название:</p>
<input value="@ViewBag.Specialization.Name" type="text" id="name-input" name="name" class="form-control mb-3" />
<button id="update-button" type="button" class="button-primary text-button">
Сохранить изменения
</button>
}
<script src="~/js/Specializations/specialization-update.js" asp-append-version="true"></script>

View File

@ -0,0 +1,3 @@
@using CaseAccountingCustomerView
@using CaseAccountingCustomerView.Models
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

View File

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

View File

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -0,0 +1,11 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"IPAddress": "http://localhost:5146"
}

View File

@ -0,0 +1,18 @@
html {
font-size: 14px;
}
@media (min-width: 768px) {
html {
font-size: 16px;
}
}
html {
position: relative;
min-height: 100%;
}
body {
margin-bottom: 60px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -0,0 +1,40 @@
const createBtn = document.getElementById("create-button");
const serviceInput = document.getElementById("service-input")
const coastInput = document.getElementById("coast-input")
const dateInput = document.getElementById("date-input")
createBtn.addEventListener("click", () => {
if (!correctData()) {
return;
}
if (!validate()) {
return;
}
});
const correctData = function () {
return true;
};
const validate = function () {
return true;
};
createBtn.addEventListener("click", () => {
let contract = {
"Service": serviceInput.value,
"Coast": parseFloat(coastInput.value),
"Date": new Date(dateInput.value),
};
console.log(contract)
$.ajax({
url: "/contracts/create",
type: "POST",
contentType: "application/json",
data: JSON.stringify(contract)
}).done(() => {
window.location.href = "/Home/Contracts";
});
});

View File

@ -0,0 +1,42 @@
const updateBtn = document.getElementById("update-button");
const serviceInput = document.getElementById("service-input")
const coastInput = document.getElementById("coast-input")
const dateInput = document.getElementById("date-input")
const contractId = document.getElementById("contr-id").dataset.id
contracts = []
window.addEventListener("load", () => {
const contractsResponse = $.ajax({
url: `/contracts/getallbyuser`,
type: "GET",
contentType: "json"
});
contracts = contractsResponse;
})
const correctData = () => {
return true;
};
updateBtn.addEventListener("click", () => {
if (!correctData()) {
return;
}
let contract = {
"Id": parseInt(contractId),
"Service": serviceInput.value,
"Coast": parseFloat(coastInput.value),
"Date": new Date(dateInput.value),
};
console.log(contract)
$.ajax({
url: "/contracts/update",
type: "POST",
contentType: "application/json",
data: JSON.stringify(contract)
}).done(() => {
window.location.href = "/Home/Contracts";
});
});

View File

@ -0,0 +1,19 @@
const goToPageBtn = document.getElementById("go-button");
const removeButtons = document.querySelectorAll(".remove-btn");
removeButtons.forEach(function (button) {
button.addEventListener("click", function (event) {
var id = this.dataset.id;
var result = confirm("Вы уверены, что хотите удалить эту запись?");
if (result) {
$.ajax({
url: "/contracts/delete",
type: "POST",
data: { Id: id }
}).done(() => {
window.location.reload();
});
}
});
});

View File

@ -0,0 +1,90 @@
const createBtn = document.getElementById("create-button");
const tbody = document.getElementById("scrollable-table__tbody");
const nameInput = document.getElementById("name-input");
const currentLawyerId = document.getElementById("lawyer-data").dataset.id;
var cases = [];
var dataArray = [];
var currentLawyer = null;
window.addEventListener('load', async () => {
await $.ajax({
url: "/lawyers/getallcases",
type: "GET",
contentType: "json"
}).done((result) => {
cases = result;
console.log(cases)
});
await $.ajax({
url: `/lawyers/get?id=${currentLawyerId}`,
type: "GET",
contentType: "json"
}).done((result) => {
currentLawyer = result;
});
cases.forEach((_case) => createRowForCasesTable(_case));
})
createBtn.addEventListener('click', () => {
console.log("My data:")
console.log(currentLawyer);
console.log(dataArray);
var lawyerCasesUpdate = {
"Id": currentLawyer.id,
"Name": currentLawyer.name,
"Surname": currentLawyer.surname,
"Patronymic": currentLawyer.patronymic,
"SpecializationId": currentLawyer.specializationId,
"Experience": currentLawyer.experience,
"ContractViewModels": currentLawyer.contractViewModels,
"CaseViewModels": dataArray,
}
console.log(lawyerCasesUpdate);
$.ajax({
url: "/lawyers/update",
type: "POST",
contentType: "application/json",
data: JSON.stringify(lawyerCasesUpdate)
}).done(() => {
window.location.href = "/Home/Lawyers";
});
})
const createRowForCasesTable = (_case) => {
const { id, name, applicant, defendant, annotation, date, specializationId } = _case;
const row = tbody.insertRow();
row.setAttribute("data-id", id);
const cells = [name];
cells.forEach((value) => {
const cell = row.insertCell();
cell.textContent = value;
});
console.log(currentLawyer)
if (currentLawyer.lawyerCases?.find(x => parseInt(x.id) === parseInt(_case.id))) {
row.classList.add("bg-success");
dataArray.push(_case);
}
row.addEventListener('click', () => addAndRemoveFromList(row));
};
const formatDate = (dateString) => {
const date = new Date(dateString);
const year = date.getFullYear();
const month = ('0' + (date.getMonth() + 1)).slice(-2);
const day = ('0' + date.getDate()).slice(-2);
return `${year}-${month}-${day}`;
};
const addAndRemoveFromList = (row) => {
var id = parseInt(row.dataset.id);
var index = dataArray.indexOf(cases.find(x => x.id === id));
if (index === -1) {
dataArray.push(cases.find(x => x.id === id));
row.classList.add("bg-success");
} else {
dataArray.splice(index, 1);
row.classList.remove("bg-success");
}
}

View File

@ -0,0 +1,75 @@
const createBtn = document.getElementById("create-button")
const tbody = document.getElementById("scrollable-table__tbody")
const nameInput = document.getElementById("name-input")
const surnameInput = document.getElementById("surname-input")
const patronymicInput = document.getElementById("patronymic-input")
const experienceInput = document.getElementById("experience-input")
var contracts = []
var dataArray = [];
window.addEventListener('load', () => {
$.ajax({
url: "/contracts/getallbyuser",
type: "GET",
contentType: "json"
}).done((result) => {
contracts = result;
contracts.forEach((contract) => createRowForContractsTable(contract));
});
})
createBtn.addEventListener('click', () => {
var lawyer = {
"Name": nameInput.value,
"Surname": surnameInput.value,
"Patronymic": patronymicInput.value,
"Experience": parseInt(experienceInput.value),
"ContractViewModels": dataArray,
}
console.log(lawyer);
$.ajax({
url: "/lawyers/create",
type: "POST",
contentType: "application/json",
data: JSON.stringify(lawyer)
}).done(() => {
window.location.href = "/Home/Lawyers";
});
})
const createRowForContractsTable = (contract) => {
const { id, service, coast, date } = contract;
const row = tbody.insertRow();
row.setAttribute("data-id", id);
const cells = [service, coast, formatDate(date)];
cells.forEach((value) => {
const cell = row.insertCell();
cell.textContent = value;
});
row.addEventListener('click', () => addAndRemoveFromList(row));
};
const formatDate = (dateString) => {
const date = new Date(dateString);
const year = date.getFullYear();
const month = ('0' + (date.getMonth() + 1)).slice(-2);
const day = ('0' + date.getDate()).slice(-2);
return `${year}-${month}-${day}`;
};
const addAndRemoveFromList = (row) => {
var id = parseInt(row.dataset.id);
console.log(contracts.find(x => x.id === id))
var index = dataArray.indexOf(contracts.find(x => x.id === id));
if (index === -1) {
dataArray.push(contracts.find(x => x.id === id));
row.classList.add("bg-success");
} else {
dataArray.splice(index, 1);
row.classList.remove("bg-success");
}
console.log(dataArray);
}

View File

@ -0,0 +1,89 @@
const createBtn = document.getElementById("create-button");
const tbody = document.getElementById("scrollable-table__tbody");
const nameInput = document.getElementById("name-input")
const surnameInput = document.getElementById("surname-input")
const patronymicInput = document.getElementById("patronymic-input")
const experienceInput = document.getElementById("experience-input")
const currentLawyerId = document.getElementById("lawyer-id").dataset.id;
var contracts = [];
var dataArray = [];
var currentLawyer = null;
window.addEventListener('load', async () => {
await $.ajax({
url: "/contracts/getallbyuser",
type: "GET",
contentType: "json"
}).done((result) => {
contracts = result;
});
console.log(currentLawyerId)
await $.ajax({
url: `/lawyers/get?id=${currentLawyerId}`,
type: "GET",
contentType: "json"
}).done((result) => {
currentLawyer = result;
});
console.log(currentLawyerId);
console.log(currentLawyer);
contracts.forEach((contract) => {
const { id, service, coast, date } = contract;
const row = tbody.insertRow();
row.setAttribute("data-id", id);
const cells = [service, coast, formatDate(date)];
cells.forEach((value) => {
const cell = row.insertCell();
cell.textContent = value;
});
console.log(currentLawyer);
/*if (currentLawyer.сontractViewModels.find(x => parseInt(x.id) === parseInt(contract.id))) {
row.classList.add("bg-success");
dataArray.push(contract);
}*/
row.addEventListener('click', () => addAndRemoveFromList(row));
});
})
createBtn.addEventListener('click', () => {
console.log(dataArray);
var lawyerCasesUpdate = {
"Id": currentLawyerId,
"Name": nameInput.value,
"Surname": surnameInput.value,
"Patronymic": patronymicInput.value,
"Experience": parseInt(experienceInput.value),
"SpecializationId": parseInt(currentLawyer.specializationId),
"ContractViewModels": dataArray
}
$.ajax({
url: "/lawyers/update",
type: "POST",
contentType: "application/json",
data: JSON.stringify(lawyerCasesUpdate)
}).done(() => {
window.location.href = "/Home/Lawyers";
});
})
const formatDate = (dateString) => {
const date = new Date(dateString);
const year = date.getFullYear();
const month = ('0' + (date.getMonth() + 1)).slice(-2);
const day = ('0' + date.getDate()).slice(-2);
return `${year}-${month}-${day}`;
};
const addAndRemoveFromList = (row) => {
var id = parseInt(row.dataset.id);
var index = dataArray.indexOf(contracts.find(x => x.id === id));
if (index === -1) {
dataArray.push(contracts.find(x => x.id === id));
row.classList.add("bg-success");
} else {
dataArray.splice(index, 1);
row.classList.remove("bg-success");
}
}

View File

@ -0,0 +1,21 @@
const goToPageBtn = document.getElementById("go-button");
const removeButtons = document.querySelectorAll(".remove-btn");
console.log(removeButtons)
removeButtons.forEach(function (button) {
button.addEventListener("click", function (event) {
var id = this.dataset.id;
console.log(id)
var result = confirm("Вы уверены, что хотите удалить эту запись?");
if (result) {
$.ajax({
url: "/lawyers/delete",
type: "POST",
data: { Id: id }
}).done(() => {
window.location.reload();
});
}
});
});

View File

@ -0,0 +1,98 @@
const createBtn = document.getElementById("create-button")
const tbody = document.getElementById("scrollable-table__tbody")
const nameInput = document.getElementById("name-input")
var fileType = document.getElementById("file-type")
var lawyers = []
var dataArray = [];
const wordMIME = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
const excelMIME = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
window.addEventListener('load', () => {
$.ajax({
url: "/lawyers/getallbyuser",
type: "GET",
contentType: "json"
}).done((result) => {
lawyers = result;
lawyers.forEach((lawyer) => createRowForLawyersTable(lawyer));
});
})
createBtn.addEventListener('click', () => {
let listModel = {
"Lawyers": Array.from(dataArray),
"FileType": fileType.value
};
console.log(listModel);
$.ajax({
url: "/home/hearinglawyerlist",
type: "POST",
contentType: "application/json",
data: JSON.stringify(listModel)
}).done((file) => {
let byteArray = new Uint8Array(file);
saveFile(byteArray, fileType);
});
})
const saveFile = async function (bytes, fileType) {
if (window.showSaveFilePicker) {
let type;
if (fileType.value == "docx") {
type = {
description: "Microsoft Word (OpenXML)",
accept: { [wordMIME]: [".docx"] }
};
} else if (fileType.value == "xlsx") {
type = {
description: "Microsoft Excel (OpenXML)",
accept: { [excelMIME]: [".xlsx"] }
};
}
const opts = {
suggestedName: `lawyer-hearing-list.${fileType.value}`,
types: [type],
};
const handle = await showSaveFilePicker(opts);
const writable = await handle.createWritable();
await writable.write(bytes);
writable.close();
}
}
const createRowForLawyersTable = (lawyer) => {
const { id, name, surname, patronymic, experience, specialization } = lawyer;
const row = tbody.insertRow();
row.setAttribute("data-id", id);
const cells = [name, surname, patronymic, experience, specialization ];
cells.forEach((value) => {
const cell = row.insertCell();
cell.textContent = value;
});
row.addEventListener('click', () => addAndRemoveFromList(row));
};
const formatDate = (dateString) => {
const date = new Date(dateString);
const year = date.getFullYear();
const month = ('0' + (date.getMonth() + 1)).slice(-2);
const day = ('0' + date.getDate()).slice(-2);
return `${year}-${month}-${day}`;
};
const addAndRemoveFromList = (row) => {
var id = parseInt(row.dataset.id);
console.log(lawyers.find(x => x.id === id))
var index = dataArray.indexOf(lawyers.find(x => x.id === id));
if (index === -1) {
dataArray.push(lawyers.find(x => x.id === id));
row.classList.add("bg-success");
} else {
dataArray.splice(index, 1);
row.classList.remove("bg-success");
}
console.log(dataArray);
}

View File

@ -0,0 +1,36 @@
const createBtn = document.getElementById("create-button");
const nameInput = document.getElementById("name-input");
createBtn.addEventListener("click", () => {
if (!correctData()) {
return;
}
if (!validate()) {
return;
}
});
const correctData = function () {
return true;
};
const validate = function () {
return true;
};
createBtn.addEventListener("click", () => {
let specializationModel = {
"Name": nameInput.value,
};
console.log(specializationModel)
$.ajax({
url: "/specializations/create",
type: "POST",
contentType: "application/json",
data: JSON.stringify(specializationModel)
}).done(() => {
window.location.href = "/Home/Specializations";
});
});

View File

@ -0,0 +1,38 @@
const updateBtn = document.getElementById("update-button");
const nameInput = document.getElementById("name-input")
const specializationId = document.getElementById("spec-id").dataset.id
updateBtn.addEventListener("click", () => {
if (!correctData()) {
return;
}
if (!validate()) {
return;
}
});
const correctData = function () {
return true;
};
const validate = function () {
return true;
};
updateBtn.addEventListener("click", () => {
let specialization = {
"Id": parseInt(specializationId),
"Name": nameInput.value,
};
console.log(specialization)
$.ajax({
url: "/specializations/update",
type: "POST",
contentType: "application/json",
data: JSON.stringify(specialization)
}).done(() => {
window.location.href = "/Home/Specializations";
});
});

View File

@ -0,0 +1,121 @@
const select = document.getElementById("lawyersSelect");
const specializationId = document.getElementById("specializationLabel").dataset.id;
const specializationInput = document.getElementById("specializationInput");
const lawyerTable = document.getElementById("lawyerTable");
const updateBtn = document.getElementById("update-button");
var lawyers = [];
var specialization = null;
window.addEventListener("load", async () => {
try {
const lawyersResponse = await $.ajax({
url: `/lawyers/getallbyuserandspecialization?specialization=${specializationId}`,
type: "GET",
contentType: "json"
});
lawyers = lawyersResponse;
console.log(lawyers);
lawyers.forEach((lawyer) => {
createLawyerOption(lawyer);
});
const specializationResponse = await $.ajax({
url: `/specializations/get?id=${specializationId}`,
type: 'GET',
contentType: 'json'
});
specialization = specializationResponse;
fillSpecializationInput(specialization);
} catch (error) {
console.error(error);
}
});
updateBtn.addEventListener("click", () => {
if (select.selectedIndex === -1) {
return;
}
var lawyer = lawyers.find(x => x.id === parseInt(select.value));
lawyer.specializationId = specialization.id;
$.ajax({
url: "/lawyers/update",
type: "POST",
contentType: "application/json",
data: JSON.stringify(lawyer)
}).done(() => {
window.location.href = "/Home/Specializations";
});
})
const createLawyerOption = (lawyer) => {
const option = document.createElement("option");
option.value = lawyer.id;
option.innerHTML = lawyer.name + " " + lawyer.surname + " " + lawyer.patronymic + ", " + lawyer.experience;
select.appendChild(option);
select.selectedIndex = -1;
}
const fillSpecializationInput = (specialization) => {
specializationInput.value = specialization.name
}
select.addEventListener("change", () => {
lawyerTable.innerHTML = "";
const createRow = (label, value) => {
const tr = document.createElement('tr');
const tdLabel = document.createElement('td');
tdLabel.innerHTML = label;
const tdValue = document.createElement('td');
tdValue.innerHTML = value;
tr.appendChild(tdLabel);
tr.appendChild(document.createElement('td'));
tr.appendChild(document.createElement('td'));
tr.appendChild(tdValue);
return tr;
};
const lawyer = lawyers.find(x => x.id === parseInt(select.value));
const trName = createRow("Имя:", lawyer.name);
const trSurname = createRow("Фамилия:", lawyer.surname);
const trPatronymic = createRow("Отчество:", lawyer.patronymic);
const trExperience = createRow("Опыт работы:", lawyer.experience);
const trSpecializationName = document.createElement('tr');
const tdSpecializationNameField = document.createElement('td');
tdSpecializationNameField.innerHTML = "Специализация:";
const tdNewSpecializationName = document.createElement('td');
tdNewSpecializationName.innerHTML = specialization.name;
const tdArrowSpecializationName = document.createElement('td');
tdArrowSpecializationName.innerHTML = "-->";
const tdSpecializationName = createRow("", lawyer.specializationName);
trSpecializationName.appendChild(tdSpecializationNameField);
trSpecializationName.appendChild(tdNewSpecializationName);
trSpecializationName.appendChild(tdArrowSpecializationName);
trSpecializationName.appendChild(tdSpecializationName);
lawyerTable.append(
trName,
trSurname,
trPatronymic,
trExperience,
trSpecializationName
);
});
const formatDate = (dateString) => {
const date = new Date(dateString);
const year = date.getFullYear();
const month = ('0' + (date.getMonth() + 1)).slice(-2);
const day = ('0' + date.getDate()).slice(-2);
return `${year}-${month}-${day}`;
};

View File

@ -0,0 +1,19 @@
const goToPageBtn = document.getElementById("go-button");
const removeButtons = document.querySelectorAll(".remove-btn");
removeButtons.forEach(function (button) {
button.addEventListener("click", function (event) {
var id = this.dataset.id;
var result = confirm("Вы уверены, что хотите удалить эту запись?");
if (result) {
$.ajax({
url: "/specializations/delete",
type: "POST",
data: { Id: id }
}).done(() => {
window.location.reload();
});
}
});
});

View File

@ -0,0 +1,4 @@
// Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
// for details on configuring this project to bundle and minify static web assets.
// Write your JavaScript code.

View File

@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2011-2021 Twitter, Inc.
Copyright (c) 2011-2021 The Bootstrap Authors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More