Compare commits

..

30 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
142 changed files with 7031 additions and 497 deletions

View File

@ -76,6 +76,11 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
return list; return list;
} }
public List<SpecializationCasesViewModel> GetSpecializationCases()
{
return _caseStorage.GetSpecializationCases() ?? new List<SpecializationCasesViewModel>();
}
public bool Update(CaseBindingModel model) public bool Update(CaseBindingModel model)
{ {
CheckModel(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.BusinessLogicContracts;
using CaseAccountingContracts.SearchModels; using CaseAccountingContracts.SearchModels;
using CaseAccountingContracts.StoragesContracts; using CaseAccountingContracts.StoragesContracts;
@ -17,13 +19,18 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
private readonly IHearingStorage _hearingStorage; private readonly IHearingStorage _hearingStorage;
private readonly ILawyerStorage _lawyerStorage; private readonly ILawyerStorage _lawyerStorage;
private readonly ISpecializationStorage _specializationStorage; 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; _caseStorage = caseStorage;
_hearingStorage = hearingStorage; _hearingStorage = hearingStorage;
_lawyerStorage = lawyerStorage; _lawyerStorage = lawyerStorage;
_specializationStorage = specializationStorage; _specializationStorage = specializationStorage;
_wordBuilder = wordBuilder;
_excelBuilder = excelBuilder;
} }
public List<ReportHearingSpecializationViewModel> GetHearingSpecialization(ReportBindingModel model) public List<ReportHearingSpecializationViewModel> GetHearingSpecialization(ReportBindingModel model)
@ -45,34 +52,23 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
return result; return result;
} }
public List<ReportLawyerHearingViewModel> GetLawyerHearing(List<LawyerViewModel> models) public List<ReportLawyerHearingViewModel> GetLawyersHearing(List<LawyerViewModel> lawyers)
{ {
var lawyers = new List<LawyerViewModel>(); var reportRecords = new List<ReportLawyerHearingViewModel>();
foreach (var model in models) foreach (var lawyer in lawyers)
{ {
lawyers.Add(_lawyerStorage.GetElement(new LawyerSearchModel { Id = model.Id})); var hearings = _lawyerStorage.GetLawyerCases(new() { Id = lawyer.Id })
} .SelectMany(_case => _caseStorage.GetCaseHearings(new() { Id = _case.Id }))
var list = new List<ReportLawyerHearingViewModel>(); .Select(hearing => hearing.Information)
.ToList();
foreach(var lawyer in lawyers) ReportLawyerHearingViewModel reportRecord = new()
{
var record = new ReportLawyerHearingViewModel
{ {
Name = lawyer.Name, Lawyer = lawyer.Name + " " + lawyer.Surname + ", " + lawyer.Patronymic,
Surname = lawyer.Surname, Hearings = hearings
Patronymic = lawyer.Patronymic,
Hearings = new List<(DateTime Date, string Information)>()
}; };
var cases = _caseStorage.GetFullList() reportRecords.Add(reportRecord);
.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);
} }
return list; return reportRecords;
} }
public void SaveHearingSpecializationToPdfFile(ReportBindingModel model) public void SaveHearingSpecializationToPdfFile(ReportBindingModel model)
@ -89,5 +85,28 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
{ {
throw new NotImplementedException(); 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.BusinessLogicContracts;
using CaseAccountingContracts.SearchModels; using CaseAccountingContracts.SearchModels;
using CaseAccountingContracts.StoragesContracts; using CaseAccountingContracts.StoragesContracts;
@ -17,68 +19,135 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
private readonly ISpecializationStorage _specializationStorage; private readonly ISpecializationStorage _specializationStorage;
private readonly IHearingStorage _hearingStorage; private readonly IHearingStorage _hearingStorage;
private readonly ILawyerStorage _lawyerStorage; 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)); _caseStorage = caseStorage ?? throw new ArgumentNullException(nameof(caseStorage));
_specializationStorage = specializationStorage ?? throw new ArgumentNullException(nameof(specializationStorage)); _specializationStorage = specializationStorage ?? throw new ArgumentNullException(nameof(specializationStorage));
_hearingStorage = hearingStorage ?? throw new ArgumentNullException(nameof(hearingStorage)); _hearingStorage = hearingStorage ?? throw new ArgumentNullException(nameof(hearingStorage));
_lawyerStorage = lawyerStorage ?? throw new ArgumentNullException(nameof(lawyerStorage)); _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) public List<ReportCaseSpecializationViewModel> GetCaseSpecialization(List<CaseViewModel> models)
{ {
var сases = new List<CaseViewModel>(); List<ReportCaseSpecializationViewModel> list = new();
foreach (var model in models) foreach (var model in models)
сases.Add(_caseStorage.GetElement(new CaseSearchModel { Id = model.Id })); {
return сases.Select(x => new ReportCaseSpecializationViewModel { var specialization = _specializationStorage.GetElement(new SpecializationSearchModel { Id = model.SpecializationId });
CaseName = x.Name, var caseModel = _caseStorage.GetElement(new CaseSearchModel { Id = model.Id });
Applicant = x.Applicant, if (specialization == null)
Defendant = x.Defendant, {
Date = x.Date, throw new Exception("Некоректные данные по специализации");
Specialization = x.Specialization, }
}).ToList(); 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) public List<ReportHearingLawyerViewModel> GetHearingLawyer(ReportBindingModel model)
{ {
var hearings = _hearingStorage 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); .Where(x => model.DateFrom <= x.Date && model.DateTo >= x.Date);
var list = new List<ReportHearingLawyerViewModel>(); var list = new List<ReportHearingLawyerViewModel>();
foreach (var hearing in hearings) foreach (var hearing in hearings)
{ {
var record = new ReportHearingLawyerViewModel var record = new ReportHearingLawyerViewModel
{ {
Information = hearing.Information, Hearing = "Номер слушания #" + hearing.Id.ToString(),
Date = hearing.Date, CaseLawyers = new()
Lawyers = new List<(string Surname, string Name, string Patronymic)>()
}; };
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); list.Add(record);
} }
return list; return list;
} }
public void SaveCaseSpecializationToExcelFile(ReportBindingModel model) public byte[] SaveListFile(CaseSpecializationListBindingModel model)
{ {
throw new NotImplementedException(); byte[] file = Array.Empty<byte>();
//TODO
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(); byte[] file = _pdfBuilder.GetHearingLawyerReportFile(new()
//TODO {
} Title = "Отчет по слушаниям",
DateFrom = reportModel.DateFrom,
public void SaveHearingLawyerToPdfFile(ReportBindingModel model) DateTo = reportModel.DateTo,
{ Records = GetHearingLawyer(reportModel)
throw new NotImplementedException(); });
//TODO _mailSender.SendMailAsync(new()
{
MailAddress = reportModel.UserEmail,
Subject = "Отчет по слушаниям",
Text = $"За период с {reportModel.DateFrom.ToShortDateString()} " +
$"по {reportModel.DateTo.ToShortDateString()}.",
File = file
});
} }
} }
} }

View File

@ -7,18 +7,28 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <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="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\CaseAccountingContracts\CaseAccountingContracts.csproj" /> <ProjectReference Include="..\CaseAccountingContracts\CaseAccountingContracts.csproj" />
<ProjectReference Include="..\CaseAccountingDataBaseImplement\CaseAccountingDataBaseImplement.csproj" />
<ProjectReference Include="..\CaseAccountingDataModels\CaseAccountingDataModels.csproj" /> <ProjectReference Include="..\CaseAccountingDataModels\CaseAccountingDataModels.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="OfficePackage\HelperEnums\" /> <Folder Include="OfficePackage\HelperEnums\" />
<Folder Include="OfficePackage\HelperModels\" /> <Folder Include="OfficePackage\HelperModels\" />
<Folder Include="OfficePackage\Implements\" />
</ItemGroup> </ItemGroup>
</Project> </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.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace ComputersShopBusinessLogic.OfficePackage.HelperEnums namespace CaseAccountingBusinessLogic.OfficePackage.HelperEnums
{ {
public enum ExcelStyleInfoType public enum ExcelStyleInfoType
{ {

View File

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

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace ComputersShopBusinessLogic.OfficePackage.HelperEnums namespace CaseAccountingBusinessLogic.OfficePackage.HelperEnums
{ {
public enum WordJustificationType 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace ComputersShopBusinessLogic.OfficePackage.HelperModels namespace CaseAccountingBusinessLogic.OfficePackage.HelperModels
{ {
public class ExcelCellParameters public class ExcelCellParameters
{ {

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace ComputersShopBusinessLogic.OfficePackage.HelperModels namespace CaseAccountingBusinessLogic.OfficePackage.HelperModels
{ {
public class ExcelMergeParameters 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace ComputersShopBusinessLogic.OfficePackage.HelperModels namespace CaseAccountingBusinessLogic.OfficePackage.HelperModels
{ {
public class PdfParagraph public class PdfParagraph
{ {

View File

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

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace ComputersShopBusinessLogic.OfficePackage.HelperModels namespace CaseAccountingBusinessLogic.OfficePackage.HelperModels
{ {
public class WordParagraph 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace ComputersShopBusinessLogic.OfficePackage.HelperModels namespace CaseAccountingBusinessLogic.OfficePackage.HelperModels
{ {
public class WordTextProperties 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -20,5 +22,20 @@ namespace CaseAccountingContracts.BindingModels
public int Id { get; set; } public int Id { get; set; }
public Dictionary<int, ICaseModel> Cases { get; set; } = new(); 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -17,12 +20,28 @@ namespace CaseAccountingContracts.BindingModels
public int Experience { get; set; } public int Experience { get; set; }
public int SpecializationId { get; set; } public int? SpecializationId { get; set; }
public int UserId { get; set; } public int UserId { get; set; }
public int Id { 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 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 class ReportBindingModel
{ {
public string FileName { get; set; } = string.Empty; public string UserEmail { get; set; } = string.Empty;
public DateTime DateFrom { get; set; }
public DateTime? DateFrom { get; set; } public DateTime DateTo { get; set; }
public DateTime? DateTo { get; set; }
public int? UserId { get; set; } public int? UserId { get; set; }
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -17,5 +17,8 @@ namespace CaseAccountingContracts.StoragesContracts
CaseViewModel? Insert(CaseBindingModel model); CaseViewModel? Insert(CaseBindingModel model);
CaseViewModel? Update(CaseBindingModel model); CaseViewModel? Update(CaseBindingModel model);
CaseViewModel? Delete(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? Insert(LawyerBindingModel model);
LawyerViewModel? Update(LawyerBindingModel model); LawyerViewModel? Update(LawyerBindingModel model);
LawyerViewModel? Delete(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; public string Patronymic { get; set; } = string.Empty;
[DisplayName("Опыт работы")] [DisplayName("Опыт работы")]
public int Experience { get; set; } public int Experience { get; set; }
public int SpecializationId { get; set; } public int? SpecializationId { get; set; }
[DisplayName("Специализация")] [DisplayName("Специализация")]
public string Specialization { get; set; } = string.Empty; public string Specialization { get; set; } = string.Empty;
public int UserId { get; set; } public int UserId { get; set; }
public int Id { get; set; } public int Id { get; set; }
public Dictionary<int, IContractModel> Contracts { get; set; } = new(); 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 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 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 class ReportHearingLawyerViewModel
{ {
public string Information { get; set; } = string.Empty; public string Hearing { get; set; } = string.Empty;
public DateTime Date { get; set; } public List<CaseLawyerViewModel> CaseLawyers { get; set; } = new();
public List<(string Surname, string Name, string Patronymic)> Lawyers { get; set; } = new();
} }
} }

View File

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

@ -39,5 +39,25 @@ namespace CaseAccountingCustomerView
throw new Exception(result); 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

@ -37,7 +37,7 @@ namespace CaseAccountingCustomerView.Controllers
{ {
throw new Exception("Введите логин и пароль"); throw new Exception("Введите логин и пароль");
} }
APIUser.User = APIUser.GetRequest<UserViewModel>($"api/user/login?login={login}&password={password}&role={Role.Provider}"); APIUser.User = APIUser.GetRequest<UserViewModel>($"api/user/login?login={login}&password={password}&role={Role.Customer}");
if (APIUser.User == null) if (APIUser.User == null)
{ {
throw new Exception("Неверный логин/пароль"); throw new Exception("Неверный логин/пароль");
@ -56,8 +56,8 @@ namespace CaseAccountingCustomerView.Controllers
{ {
Login = login, Login = login,
Password = password, Password = password,
Role = Role.Provider Role = Role.Customer
}); });
Response.Redirect("Login"); Response.Redirect("Login");
return; return;
} }
@ -69,7 +69,7 @@ namespace CaseAccountingCustomerView.Controllers
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
ViewBag.Lawyers = APIUser.GetRequest<List<LawyerViewModel>> ViewBag.Lawyers = APIUser.GetRequest<List<LawyerViewModel>>
($"api/lawyer/getmany?userId={APIUser.User.Id}"); ($"api/lawyer/getallbyuser?userId={APIUser.User.Id}");
return View(); return View();
} }
@ -80,7 +80,7 @@ namespace CaseAccountingCustomerView.Controllers
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
ViewBag.Specializations = APIUser.GetRequest<List<SpecializationViewModel>> ViewBag.Specializations = APIUser.GetRequest<List<SpecializationViewModel>>
($"api/specialization/getmany?userId={APIUser.User.Id}"); ($"api/specialization/getallbyuser?userId={APIUser.User.Id}");
return View(); return View();
} }
@ -91,7 +91,7 @@ namespace CaseAccountingCustomerView.Controllers
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
ViewBag.Contracts = APIUser.GetRequest<List<ContractViewModel>> ViewBag.Contracts = APIUser.GetRequest<List<ContractViewModel>>
($"api/contract/getmany?userId={APIUser.User.Id}"); ($"api/contract/getallbyuser?userId={APIUser.User.Id}");
return View(); return View();
} }
@ -100,5 +100,22 @@ namespace CaseAccountingCustomerView.Controllers
{ {
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); 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

@ -1,5 +1,6 @@
using CaseAccountingContracts.BindingModels; using CaseAccountingContracts.BindingModels;
using CaseAccountingContracts.ViewModels; using CaseAccountingContracts.ViewModels;
using CaseAccountingDataModels.Models;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace CaseAccountingCustomerView.Controllers namespace CaseAccountingCustomerView.Controllers
@ -23,6 +24,14 @@ namespace CaseAccountingCustomerView.Controllers
throw new Exception("403"); throw new Exception("403");
} }
lawyerModel.UserId = APIUser.User.Id; 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); APIUser.PostRequest("api/lawyer/create", lawyerModel);
Response.Redirect("/Home/Lawyers"); Response.Redirect("/Home/Lawyers");
} }
@ -45,6 +54,20 @@ namespace CaseAccountingCustomerView.Controllers
throw new Exception("403"); throw new Exception("403");
} }
lawyerModel.UserId = APIUser.User.Id; 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); APIUser.PostRequest("api/lawyer/update", lawyerModel);
Response.Redirect("/Home/Lawyers"); Response.Redirect("/Home/Lawyers");
} }
@ -70,16 +93,6 @@ namespace CaseAccountingCustomerView.Controllers
return lawyers ?? new(); return lawyers ?? new();
} }
/*public List<EducationGroupViewModel> GetAllCases()
{
if (APIUser.User == null)
{
return new();
}
List<EducationGroupViewModel>? group = APIUser.GetRequest<List<EducationGroupViewModel>>("api/lawyer/GetAllCases");
return group ?? new();
}*/
public LawyerViewModel? Get(int id) public LawyerViewModel? Get(int id)
{ {
if (APIUser.User == null) if (APIUser.User == null)
@ -100,6 +113,16 @@ namespace CaseAccountingCustomerView.Controllers
return View(); 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) public List<LawyerViewModel> GetAllByUserAndSpecialization(int specialization)
{ {
if (APIUser.User == null) if (APIUser.User == null)
@ -109,6 +132,17 @@ namespace CaseAccountingCustomerView.Controllers
List<LawyerViewModel>? lawyers = APIUser.GetRequest<List<LawyerViewModel>>($"api/lawyer/getallbyuserandspecialization?userId={APIUser.User.Id}&specialization={specialization}"); List<LawyerViewModel>? lawyers = APIUser.GetRequest<List<LawyerViewModel>>($"api/lawyer/getallbyuserandspecialization?userId={APIUser.User.Id}&specialization={specialization}");
return lawyers ?? new(); 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

@ -79,5 +79,24 @@ namespace CaseAccountingCustomerView.Controllers
SpecializationViewModel? specialization = APIUser.GetRequest<SpecializationViewModel>($"api/specialization/get?id={id}"); SpecializationViewModel? specialization = APIUser.GetRequest<SpecializationViewModel>($"api/specialization/get?id={id}");
return specialization; 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

@ -21,4 +21,4 @@
Создать Создать
</button> </button>
<script src="~/js/contract/contract-create.js" asp-append-version="true"></script> <script src="~/js/Contracts/contract-create.js" asp-append-version="true"></script>

View File

@ -6,7 +6,7 @@
@{ @{
<h4 class="fw-bold" id="vb-id" data-id="@ViewBag.Contract.Id">Изменение данных контракта</h4> <h4 class="fw-bold" id="contr-id" data-id="@ViewBag.Contract.Id">Изменение данных контракта</h4>
if (ViewBag.Contract == null) if (ViewBag.Contract == null)
{ {
@ -31,4 +31,4 @@
</button> </button>
} }
<script src="~/js/contract/contract-update.js" asp-append-version="true"></script> <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

@ -16,16 +16,7 @@
return; return;
} }
<div> <div>
<a class="btn btn-secondary" asp-controller="Lawyer" asp-action="Create">Добавить юриста</a> <a class="btn btn-secondary" asp-controller="Lawyers" asp-action="Create">Добавить юриста</a>
</div>
<div class="d-flex mb-2 gap-1">
<div class="input-group" style="width: auto;">
<input id="page-input" type="number" min="1" value="@ViewBag.Page" max="@ViewBag.NumberOfPages" class="form-control" style="max-width: 5em">
<span class="input-group-text">/ @ViewBag.NumberOfPages</span>
</div>
<a href="/Home/Lawyers?page=@ViewBag.Page" id="go-button" class="button-primary text-button">
Перейти
</a>
</div> </div>
<table class="table"> <table class="table">
<thead> <thead>
@ -55,13 +46,16 @@
@item.Name @item.Surname @item.Patronymic @item.Name @item.Surname @item.Patronymic
</td> </td>
<td> <td>
@item.StudentCard @item.Experience
</td> </td>
<td> <td>
@item.EducationStatusName @item.Specialization
</td> </td>
<td> <td>
<a id="update-button-@item.Id" class="btn btn-secondary" asp-controller="Lawyer" asp-action="Update" asp-route-id="@item.Id">Изменить</a> <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>
<td> <td>
<a id="remove-button-@item.Id" class="btn btn-secondary remove-btn" data-id="@item.Id">Удалить</a> <a id="remove-button-@item.Id" class="btn btn-secondary remove-btn" data-id="@item.Id">Удалить</a>
@ -73,4 +67,4 @@
} }
</div> </div>
<script src="~/js/lawyer/lawyers.js" asp-append-version="true"></script> <script src="~/js/Lawyers/lawyers.js" asp-append-version="true"></script>

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

@ -12,7 +12,7 @@
</div> </div>
<p class="mb-0">Название:</p> <p class="mb-0">Название:</p>
<input type="text" readonly value="@ViewBag.Document.Name" id="name-input" name="name" class="form-control mb-3" /> <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 id="create-button" type="button" class="button-primary text-button">
Сохранить привязку Сохранить привязку
@ -23,7 +23,7 @@
<table class="table table-bordered"> <table class="table table-bordered">
<thead class="thead-light"> <thead class="thead-light">
<tr> <tr>
<th>Название группы:</th> <th>Название дела:</th>
</tr> </tr>
</thead> </thead>
<tbody id="scrollable-table__tbody"> <tbody id="scrollable-table__tbody">
@ -32,4 +32,4 @@
</div> </div>
</div> </div>
} }
<script src="~/js/document/document-bind.js" asp-append-version="true"></script> <script src="~/js/Lawyers/lawyer-bind.js" asp-append-version="true"></script>

View File

@ -19,8 +19,24 @@
<p class="mb-0">Опыт работы:</p> <p class="mb-0">Опыт работы:</p>
<input type="number" id="experience-input" name="experience" class="form-control mb-3" /> <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 id="create-button" type="button" class="button-primary text-button">
Создать Создать
</button> </button>
<script src="~/js/lawyer/lawyer-create.js" asp-append-version="true"></script> <script src="~/js/Lawyers/lawyer-create.js" asp-append-version="true"></script>

View File

@ -6,7 +6,7 @@
@{ @{
<h4 class="fw-bold" id="vb-id" data-id="@ViewBag.Lawyer.Id">Изменение данных юриста</h4> <h4 class="fw-bold" id="lawyer-id" data-id="@ViewBag.Lawyer.Id">Изменение данных юриста</h4>
if (ViewBag.Lawyer == null) if (ViewBag.Lawyer == null)
{ {
@ -28,9 +28,25 @@
<p class="mb-0">Опыт работы:</p> <p class="mb-0">Опыт работы:</p>
<input value="@ViewBag.Lawyer.Experience" type="number" id="experience-input" name="experience" class="form-control mb-3" /> <input value="@ViewBag.Lawyer.Experience" type="number" id="experience-input" name="experience" class="form-control mb-3" />
<button id="update-button" type="button" class="button-primary text-button"> <button id="create-button" type="button" class="btn btn-primary text-button">
Сохранить изменения Сохранить изменения
</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/lawyer/lawyer-update.js" asp-append-version="true"></script> <script src="~/js/Lawyers/lawyer-update.js" asp-append-version="true"></script>

View File

@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - CaseAccountingCustomerView</title> <title>@ViewData["Title"] - Юридическая фирма «Вас обманут» "Заказчик"</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" /> <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="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/CaseAccountingCustomerView.styles.css" asp-append-version="true" /> <link rel="stylesheet" href="~/CaseAccountingCustomerView.styles.css" asp-append-version="true" />
@ -12,7 +12,7 @@
<header> <header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3"> <nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container-fluid"> <div class="container-fluid">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">CaseAccountingCustomerView</a> <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" <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"> aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
@ -20,10 +20,19 @@
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between"> <div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1"> <ul class="navbar-nav flex-grow-1">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Contracts">Контракты</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a> <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> </li>
</ul> </ul>
</div> </div>
@ -38,7 +47,7 @@
<footer class="border-top footer text-muted"> <footer class="border-top footer text-muted">
<div class="container"> <div class="container">
&copy; 2023 - CaseAccountingCustomerView - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a> &copy; Юридическая фирма «Вас обманут» "Заказчик" - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</div> </div>
</footer> </footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script> <script src="~/lib/jquery/dist/jquery.min.js"></script>

View File

@ -54,4 +54,4 @@
</div> </div>
} }
<script src="~/js/specialization/specialization-add-student.js" asp-append-version="true"></script> <script src="~/js/Specializations/specializations-add-lawyer.js" asp-append-version="true"></script>

View File

@ -17,4 +17,4 @@
Создать Создать
</button> </button>
<script src="~/js/specialization/specialization-create.js" asp-append-version="true"></script> <script src="~/js/Specializations/specialization-create.js" asp-append-version="true"></script>

View File

@ -6,9 +6,9 @@
@{ @{
<h4 class="fw-bold" id="vb-id" data-id="@ViewBag.Specialization.Id">Изменение данных специализации</h4> <h4 class="fw-bold" id="spec-id" data-id="@ViewBag.Specialization.Id">Изменение данных специализации</h4>
if (ViewBag.EducationStatus == null) if (ViewBag.Specialization == null)
{ {
<h3 class="display-4">Войдите в аккаунт</h3> <h3 class="display-4">Войдите в аккаунт</h3>
return; return;
@ -27,4 +27,4 @@
</button> </button>
} }
<script src="~/js/specialization/specialization-update.js" asp-append-version="true"></script> <script src="~/js/Specializations/specialization-update.js" asp-append-version="true"></script>

View File

@ -7,5 +7,5 @@
}, },
"AllowedHosts": "*", "AllowedHosts": "*",
"IPAddress": "http://localhost:5146/" "IPAddress": "http://localhost:5146"
} }

View File

@ -30,7 +30,7 @@ createBtn.addEventListener("click", () => {
}; };
console.log(contract) console.log(contract)
$.ajax({ $.ajax({
url: "/contract/create", url: "/contracts/create",
type: "POST", type: "POST",
contentType: "application/json", contentType: "application/json",
data: JSON.stringify(contract) data: JSON.stringify(contract)

View File

@ -4,26 +4,26 @@ const coastInput = document.getElementById("coast-input")
const dateInput = document.getElementById("date-input") const dateInput = document.getElementById("date-input")
const contractId = document.getElementById("contr-id").dataset.id 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", () => { updateBtn.addEventListener("click", () => {
if (!correctData()) { if (!correctData()) {
return; return;
} }
if (!validate()) {
return;
}
});
const correctData = function () {
return true;
};
const validate = function () {
return true;
};
updateBtn.addEventListener("click", () => {
let contract = { let contract = {
"Id": parseInt(contractId), "Id": parseInt(contractId),
"Service": serviceInput.value, "Service": serviceInput.value,
@ -32,7 +32,7 @@ updateBtn.addEventListener("click", () => {
}; };
console.log(contract) console.log(contract)
$.ajax({ $.ajax({
url: "/lawyer/update", url: "/contracts/update",
type: "POST", type: "POST",
contentType: "application/json", contentType: "application/json",
data: JSON.stringify(contract) data: JSON.stringify(contract)

View File

@ -8,7 +8,7 @@ removeButtons.forEach(function (button) {
var result = confirm("Вы уверены, что хотите удалить эту запись?"); var result = confirm("Вы уверены, что хотите удалить эту запись?");
if (result) { if (result) {
$.ajax({ $.ajax({
url: "/contract/delete", url: "/contracts/delete",
type: "POST", type: "POST",
data: { Id: id } data: { Id: id }
}).done(() => { }).done(() => {

View File

@ -4,48 +4,54 @@ const nameInput = document.getElementById("name-input");
const currentLawyerId = document.getElementById("lawyer-data").dataset.id; const currentLawyerId = document.getElementById("lawyer-data").dataset.id;
var cases = []; var cases = [];
var dataArray = []; var dataArray = [];
var currentlawyer = null; var currentLawyer = null;
window.addEventListener('load', async () => { window.addEventListener('load', async () => {
await $.ajax({ await $.ajax({
url: "/lawyer/getallgroups", url: "/lawyers/getallcases",
type: "GET", type: "GET",
contentType: "json" contentType: "json"
}).done((result) => { }).done((result) => {
groups = result; cases = result;
console.log(groups) console.log(cases)
}); });
await $.ajax({ await $.ajax({
url: `/document/get?id=${currentDocumentId}`, url: `/lawyers/get?id=${currentLawyerId}`,
type: "GET", type: "GET",
contentType: "json" contentType: "json"
}).done((result) => { }).done((result) => {
currentDocument = result; currentLawyer = result;
console.log(currentDocument)
}); });
groups.forEach((group) => createRowForGroupsTable(group)); cases.forEach((_case) => createRowForCasesTable(_case));
}) })
createBtn.addEventListener('click', () => { createBtn.addEventListener('click', () => {
var documentGroupsUpdate = { console.log("My data:")
"Id": currentDocument.id, console.log(currentLawyer);
"Name": currentDocument.name, console.log(dataArray);
"Date": currentDocument.date, var lawyerCasesUpdate = {
"DocumentStudents": currentDocument.documentStudents, "Id": currentLawyer.id,
"DocumentGroups": dataArray, "Name": currentLawyer.name,
"Surname": currentLawyer.surname,
"Patronymic": currentLawyer.patronymic,
"SpecializationId": currentLawyer.specializationId,
"Experience": currentLawyer.experience,
"ContractViewModels": currentLawyer.contractViewModels,
"CaseViewModels": dataArray,
} }
console.log(lawyerCasesUpdate);
$.ajax({ $.ajax({
url: "/document/update", url: "/lawyers/update",
type: "POST", type: "POST",
contentType: "application/json", contentType: "application/json",
data: JSON.stringify(documentGroupsUpdate) data: JSON.stringify(lawyerCasesUpdate)
}).done(() => { }).done(() => {
window.location.href = "/Home/Documents"; window.location.href = "/Home/Lawyers";
}); });
}) })
const createRowForGroupsTable = (group) => { const createRowForCasesTable = (_case) => {
const { id, name } = group; const { id, name, applicant, defendant, annotation, date, specializationId } = _case;
const row = tbody.insertRow(); const row = tbody.insertRow();
row.setAttribute("data-id", id); row.setAttribute("data-id", id);
@ -54,10 +60,10 @@ const createRowForGroupsTable = (group) => {
const cell = row.insertCell(); const cell = row.insertCell();
cell.textContent = value; cell.textContent = value;
}); });
console.log(currentDocument) console.log(currentLawyer)
if (currentDocument.documentEdGroups?.find(x => parseInt(x.id) === parseInt(group.id))) { if (currentLawyer.lawyerCases?.find(x => parseInt(x.id) === parseInt(_case.id))) {
row.classList.add("bg-success"); row.classList.add("bg-success");
dataArray.push(group); dataArray.push(_case);
} }
row.addEventListener('click', () => addAndRemoveFromList(row)); row.addEventListener('click', () => addAndRemoveFromList(row));
@ -73,9 +79,9 @@ const formatDate = (dateString) => {
const addAndRemoveFromList = (row) => { const addAndRemoveFromList = (row) => {
var id = parseInt(row.dataset.id); var id = parseInt(row.dataset.id);
var index = dataArray.indexOf(groups.find(x => x.id === id)); var index = dataArray.indexOf(cases.find(x => x.id === id));
if (index === -1) { if (index === -1) {
dataArray.push(groups.find(x => x.id === id)); dataArray.push(cases.find(x => x.id === id));
row.classList.add("bg-success"); row.classList.add("bg-success");
} else { } else {
dataArray.splice(index, 1); dataArray.splice(index, 1);

View File

@ -10,12 +10,12 @@ var dataArray = [];
window.addEventListener('load', () => { window.addEventListener('load', () => {
$.ajax({ $.ajax({
url: "/contract/getallbyuser", url: "/contracts/getallbyuser",
type: "GET", type: "GET",
contentType: "json" contentType: "json"
}).done((result) => { }).done((result) => {
contracts = result; contracts = result;
contracts.forEach((contract) => createRowForStudentsTable(contract)); contracts.forEach((contract) => createRowForContractsTable(contract));
}); });
}) })
@ -25,10 +25,11 @@ createBtn.addEventListener('click', () => {
"Surname": surnameInput.value, "Surname": surnameInput.value,
"Patronymic": patronymicInput.value, "Patronymic": patronymicInput.value,
"Experience": parseInt(experienceInput.value), "Experience": parseInt(experienceInput.value),
"LawyerContracts": dataArray, "ContractViewModels": dataArray,
} }
console.log(lawyer);
$.ajax({ $.ajax({
url: "/lawyer/create", url: "/lawyers/create",
type: "POST", type: "POST",
contentType: "application/json", contentType: "application/json",
data: JSON.stringify(lawyer) data: JSON.stringify(lawyer)

View File

@ -1,67 +1,72 @@
const createBtn = document.getElementById("create-button"); const createBtn = document.getElementById("create-button");
const tbody = document.getElementById("scrollable-table__tbody"); const tbody = document.getElementById("scrollable-table__tbody");
const serviceInput = document.getElementById("service-input"); const nameInput = document.getElementById("name-input")
const coastInput = document.getElementById("coast-input"); const surnameInput = document.getElementById("surname-input")
const currentLawyerId = document.getElementById("lawyer-data").dataset.id; const patronymicInput = document.getElementById("patronymic-input")
const experienceInput = document.getElementById("experience-input")
const currentLawyerId = document.getElementById("lawyer-id").dataset.id;
var contracts = []; var contracts = [];
var dataArray = []; var dataArray = [];
var currentLawyer = null; var currentLawyer = null;
window.addEventListener('load', async () => { window.addEventListener('load', async () => {
await $.ajax({ await $.ajax({
url: "/contract/getallbyuser", url: "/contracts/getallbyuser",
type: "GET", type: "GET",
contentType: "json" contentType: "json"
}).done((result) => { }).done((result) => {
contracts = result; contracts = result;
}); });
console.log(currentLawyerId)
await $.ajax({ await $.ajax({
url: `/lawyer/get?id=${currentLawyerId}`, url: `/lawyers/get?id=${currentLawyerId}`,
type: "GET", type: "GET",
contentType: "json" contentType: "json"
}).done((result) => { }).done((result) => {
currentLawyer = result; currentLawyer = result;
}); });
contracts.forEach((contract) => createRowForContractsTable(contract)); 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', () => { createBtn.addEventListener('click', () => {
console.log(dataArray);
var lawyerCasesUpdate = { var lawyerCasesUpdate = {
"Id": currentLawyer.id, "Id": currentLawyerId,
"Service": serviceInput.value, "Name": nameInput.value,
"Coast": coastInput.value, "Surname": surnameInput.value,
"Date": currentLawyer.date, "Patronymic": patronymicInput.value,
"LawyerContracts": dataArray, "Experience": parseInt(experienceInput.value),
"LawyerCases": currentLawyer.lawyerCases, "SpecializationId": parseInt(currentLawyer.specializationId),
"ContractViewModels": dataArray
} }
$.ajax({ $.ajax({
url: "/lawyer/update", url: "/lawyers/update",
type: "POST", type: "POST",
contentType: "application/json", contentType: "application/json",
data: JSON.stringify(lawyerCasesUpdate) data: JSON.stringify(lawyerCasesUpdate)
}).done(() => { }).done(() => {
window.location.href = "/Home/Lawyers"; 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;
});
if (currentLawyer.lawyerContracts.find(x => parseInt(x.id) === parseInt(contract.id))) {
row.classList.add("bg-success");
dataArray.push(contract);
}
row.addEventListener('click', () => addAndRemoveFromList(row));
};
const formatDate = (dateString) => { const formatDate = (dateString) => {
const date = new Date(dateString); const date = new Date(dateString);

View File

@ -10,7 +10,7 @@ removeButtons.forEach(function (button) {
var result = confirm("Вы уверены, что хотите удалить эту запись?"); var result = confirm("Вы уверены, что хотите удалить эту запись?");
if (result) { if (result) {
$.ajax({ $.ajax({
url: "/lawyer/delete", url: "/lawyers/delete",
type: "POST", type: "POST",
data: { Id: id } data: { Id: id }
}).done(() => { }).done(() => {

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

@ -21,15 +21,15 @@ const validate = function () {
}; };
createBtn.addEventListener("click", () => { createBtn.addEventListener("click", () => {
let specialization = { let specializationModel = {
"Name": nameInput.value, "Name": nameInput.value,
}; };
console.log(specialization) console.log(specializationModel)
$.ajax({ $.ajax({
url: "/specialization/create", url: "/specializations/create",
type: "POST", type: "POST",
contentType: "application/json", contentType: "application/json",
data: JSON.stringify(specialization) data: JSON.stringify(specializationModel)
}).done(() => { }).done(() => {
window.location.href = "/Home/Specializations"; window.location.href = "/Home/Specializations";
}); });

View File

@ -28,7 +28,7 @@ updateBtn.addEventListener("click", () => {
}; };
console.log(specialization) console.log(specialization)
$.ajax({ $.ajax({
url: "/specialization/update", url: "/specializations/update",
type: "POST", type: "POST",
contentType: "application/json", contentType: "application/json",
data: JSON.stringify(specialization) data: JSON.stringify(specialization)

View File

@ -10,18 +10,19 @@ var specialization = null;
window.addEventListener("load", async () => { window.addEventListener("load", async () => {
try { try {
const lawyersResponse = await $.ajax({ const lawyersResponse = await $.ajax({
url: `/lawyer/getallbyuserandspecialization?specialization=${specializationId}`, url: `/lawyers/getallbyuserandspecialization?specialization=${specializationId}`,
type: "GET", type: "GET",
contentType: "json" contentType: "json"
}); });
lawyers = lawyersResponse; lawyers = lawyersResponse;
console.log(lawyers);
lawyers.forEach((lawyer) => { lawyers.forEach((lawyer) => {
createLawyerOption(lawyer); createLawyerOption(lawyer);
}); });
const specializationResponse = await $.ajax({ const specializationResponse = await $.ajax({
url: `/specialization/get?id=${specializationId}`, url: `/specializations/get?id=${specializationId}`,
type: 'GET', type: 'GET',
contentType: 'json' contentType: 'json'
}); });
@ -42,7 +43,7 @@ updateBtn.addEventListener("click", () => {
lawyer.specializationId = specialization.id; lawyer.specializationId = specialization.id;
$.ajax({ $.ajax({
url: "/lawyer/update", url: "/lawyers/update",
type: "POST", type: "POST",
contentType: "application/json", contentType: "application/json",
data: JSON.stringify(lawyer) data: JSON.stringify(lawyer)

View File

@ -8,7 +8,7 @@ removeButtons.forEach(function (button) {
var result = confirm("Вы уверены, что хотите удалить эту запись?"); var result = confirm("Вы уверены, что хотите удалить эту запись?");
if (result) { if (result) {
$.ajax({ $.ajax({
url: "/specialization/delete", url: "/specializations/delete",
type: "POST", type: "POST",
data: { Id: id } data: { Id: id }
}).done(() => { }).done(() => {

View File

@ -18,8 +18,8 @@ namespace CaseAccountingDataBaseImplement
Host=localhost; Host=localhost;
Port=5432; Port=5432;
Database=CaseAccountingDatabase; Database=CaseAccountingDatabase;
Username=postgres; Username=courseuser;
Password=postgres"); Password=courseuser");
} }
base.OnConfiguring(optionsBuilder); base.OnConfiguring(optionsBuilder);
} }

View File

@ -158,7 +158,7 @@ namespace CaseAccountingDataBaseImplement.Implements
{ {
return null; return null;
} }
_case.Update(model); _case.Update(context, model);
context.SaveChanges(); context.SaveChanges();
_case.UpdateLawyers(context, model); _case.UpdateLawyers(context, model);
transaction.Commit(); transaction.Commit();
@ -170,5 +170,37 @@ namespace CaseAccountingDataBaseImplement.Implements
throw; throw;
} }
} }
public List<HearingViewModel> GetCaseHearings(CaseSearchModel model)
{
if (model == null)
{
return new();
}
using var context = new CaseAccountingDatabase();
var hearings = context.Hearings
.Where(x => x.CaseId == model.Id)
.Select(x => x.GetViewModel)
.ToList();
return hearings;
}
public List<SpecializationCasesViewModel>? GetSpecializationCases()
{
using var context = new CaseAccountingDatabase();
var result = context.Specializations
.GroupJoin(
context.Cases,
status => status.Id,
caseModel => caseModel.SpecializationId,
(status, caseModels) => new SpecializationCasesViewModel
{
Name = status.Name,
Count = caseModels.Count()
})
.ToList();
return result;
}
} }
} }

View File

@ -86,14 +86,13 @@ namespace CaseAccountingDataBaseImplement.Implements
public ContractViewModel? Insert(ContractBindingModel model) public ContractViewModel? Insert(ContractBindingModel model)
{ {
var newContract = Contract.Create(model); using var context = new CaseAccountingDatabase();
var newContract = Contract.Create(context, model);
if (newContract == null) if (newContract == null)
{ {
return null; return null;
} }
using var context = new CaseAccountingDatabase();
context.Contracts.Add(newContract); context.Contracts.Add(newContract);
context.SaveChanges(); context.SaveChanges();
return context.Contracts return context.Contracts

View File

@ -115,9 +115,9 @@ namespace CaseAccountingDataBaseImplement.Implements
{ {
return null; return null;
} }
deal.Update(model); deal.Update(context, model);
context.SaveChanges(); context.SaveChanges();
deal.UpdateCases(context, model); if(model.Cases.Count > 0) deal.UpdateCases(context, model);
transaction.Commit(); transaction.Commit();
return deal.GetViewModel; return deal.GetViewModel;
} }

View File

@ -129,7 +129,7 @@ namespace CaseAccountingDataBaseImplement.Implements
{ {
return null; return null;
} }
hearing.Update(model); hearing.Update(context, model);
context.SaveChanges(); context.SaveChanges();
return context.Hearings return context.Hearings
.Include(x => x.Case) .Include(x => x.Case)

View File

@ -89,15 +89,29 @@ namespace CaseAccountingDataBaseImplement.Implements
.Select(x => x.GetViewModel).ToList(); .Select(x => x.GetViewModel).ToList();
} }
public List<LawyerViewModel> GetLawyerMTM(int caseId)
{
using var context = new CaseAccountingDatabase();
var lawyersId = context.CaseLawyers
.Where(x => x.CaseId == caseId)
.Select(x => x.LawyerId).ToList();
return context.Lawyers
.Include(x => x.Specialization)
.Include(x => x.User)
.Where(X => lawyersId.Contains(X.Id))
.Select(x => x.GetViewModel)
.ToList();
}
public LawyerViewModel? Insert(LawyerBindingModel model) public LawyerViewModel? Insert(LawyerBindingModel model)
{ {
var newLawyer = Lawyer.Create(model); using var context = new CaseAccountingDatabase();
var newLawyer = Lawyer.Create(context, model);
if (newLawyer == null) if (newLawyer == null)
{ {
return null; return null;
} }
using var context = new CaseAccountingDatabase();
context.Lawyers.Add(newLawyer); context.Lawyers.Add(newLawyer);
context.SaveChanges(); context.SaveChanges();
@ -123,9 +137,12 @@ namespace CaseAccountingDataBaseImplement.Implements
{ {
return null; return null;
} }
lawyer.Update(model); lawyer.Update(context, model);
context.SaveChanges(); context.SaveChanges();
lawyer.UpdateContracts(context, model); if (model.Cases.Count > 0)
{
lawyer.UpdateContracts(context, model);
}
transaction.Commit(); transaction.Commit();
return lawyer.GetViewModel; return lawyer.GetViewModel;
} }
@ -135,5 +152,19 @@ namespace CaseAccountingDataBaseImplement.Implements
throw; throw;
} }
} }
public List<CaseViewModel> GetLawyerCases(LawyerSearchModel model)
{
if (model == null)
{
return new();
}
using var context = new CaseAccountingDatabase();
var cases = context.CaseLawyers
.Where(x => x.LawyerId == model.Id)
.Select(x => x.Case.GetViewModel)
.ToList();
return cases;
}
} }
} }

View File

@ -85,14 +85,14 @@ namespace CaseAccountingDataBaseImplement.Implements
public SpecializationViewModel? Insert(SpecializationBindingModel model) public SpecializationViewModel? Insert(SpecializationBindingModel model)
{ {
var newSpecialization = Specialization.Create(model); using var context = new CaseAccountingDatabase();
var newSpecialization = Specialization.Create(context, model);
if (newSpecialization == null) if (newSpecialization == null)
{ {
return null; return null;
} }
using var context = new CaseAccountingDatabase();
context.Specializations.Add(newSpecialization); context.Specializations.Add(newSpecialization);
context.SaveChanges(); context.SaveChanges();
return context.Specializations return context.Specializations

View File

@ -0,0 +1,553 @@
// <auto-generated />
using System;
using CaseAccountingDataBaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace CaseAccountingDataBaseImplement.Migrations
{
[DbContext(typeof(CaseAccountingDatabase))]
[Migration("20230518222251_MergMig")]
partial class MergMig
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Annotation")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Applicant")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Defendant")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("SpecializationId")
.HasColumnType("integer");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("SpecializationId");
b.HasIndex("UserId");
b.ToTable("Cases");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseDeal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CaseId")
.HasColumnType("integer");
b.Property<int>("DealId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CaseId");
b.HasIndex("DealId");
b.ToTable("CaseDeals");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseLawyer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CaseId")
.HasColumnType("integer");
b.Property<int>("LawyerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CaseId");
b.HasIndex("LawyerId");
b.ToTable("CaseLawyers");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<decimal>("Coast")
.HasColumnType("numeric");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Service")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Contracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Responsibilities")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Subject")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Deals");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.DealContract", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ContractId")
.HasColumnType("integer");
b.Property<int>("DealId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ContractId");
b.HasIndex("DealId");
b.ToTable("DealContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Hearing", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CaseId")
.HasColumnType("integer");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Information")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CaseId");
b.HasIndex("UserId");
b.ToTable("Hearings");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Experience")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Patronymic")
.IsRequired()
.HasColumnType("text");
b.Property<int>("SpecializationId")
.HasColumnType("integer");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("SpecializationId");
b.HasIndex("UserId");
b.ToTable("Lawyers");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.LawyerContract", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ContractId")
.HasColumnType("integer");
b.Property<int>("LawyerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ContractId");
b.HasIndex("LawyerId");
b.ToTable("LawyerContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Specializations");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Login")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Role")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Specialization", "Specialization")
.WithMany("Cases")
.HasForeignKey("SpecializationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Cases")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Specialization");
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseDeal", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case")
.WithMany("Deals")
.HasForeignKey("CaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Deal", "Deal")
.WithMany("CaseDeals")
.HasForeignKey("DealId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Case");
b.Navigation("Deal");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseLawyer", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case")
.WithMany("CaseLawyers")
.HasForeignKey("CaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Lawyer", "Lawyer")
.WithMany("CaseLawyers")
.HasForeignKey("LawyerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Case");
b.Navigation("Lawyer");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Contracts")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Deals")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.DealContract", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Contract", "Contract")
.WithMany("DealContracts")
.HasForeignKey("ContractId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Deal", "Deal")
.WithMany("Contracts")
.HasForeignKey("DealId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Contract");
b.Navigation("Deal");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Hearing", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case")
.WithMany("Hearings")
.HasForeignKey("CaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Hearings")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Case");
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Specialization", "Specialization")
.WithMany("Lawyers")
.HasForeignKey("SpecializationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Lawyers")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Specialization");
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.LawyerContract", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Contract", "Contract")
.WithMany("LawyerContracts")
.HasForeignKey("ContractId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Lawyer", "Lawyer")
.WithMany("LawyerContracts")
.HasForeignKey("LawyerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Contract");
b.Navigation("Lawyer");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Specializations")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b =>
{
b.Navigation("CaseLawyers");
b.Navigation("Deals");
b.Navigation("Hearings");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b =>
{
b.Navigation("DealContracts");
b.Navigation("LawyerContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b =>
{
b.Navigation("CaseDeals");
b.Navigation("Contracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b =>
{
b.Navigation("CaseLawyers");
b.Navigation("LawyerContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b =>
{
b.Navigation("Cases");
b.Navigation("Lawyers");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.User", b =>
{
b.Navigation("Cases");
b.Navigation("Contracts");
b.Navigation("Deals");
b.Navigation("Hearings");
b.Navigation("Lawyers");
b.Navigation("Specializations");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CaseAccountingDataBaseImplement.Migrations
{
/// <inheritdoc />
public partial class MergMig : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -0,0 +1,554 @@
// <auto-generated />
using System;
using CaseAccountingDataBaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace CaseAccountingDataBaseImplement.Migrations
{
[DbContext(typeof(CaseAccountingDatabase))]
[Migration("20230519143905_migrSpecializationNull")]
partial class migrSpecializationNull
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Annotation")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Applicant")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Defendant")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("SpecializationId")
.HasColumnType("integer");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("SpecializationId");
b.HasIndex("UserId");
b.ToTable("Cases");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseDeal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CaseId")
.HasColumnType("integer");
b.Property<int>("DealId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CaseId");
b.HasIndex("DealId");
b.ToTable("CaseDeals");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseLawyer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CaseId")
.HasColumnType("integer");
b.Property<int>("LawyerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CaseId");
b.HasIndex("LawyerId");
b.ToTable("CaseLawyers");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<decimal>("Coast")
.HasColumnType("numeric");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Service")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Contracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Responsibilities")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Subject")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Deals");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.DealContract", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ContractId")
.HasColumnType("integer");
b.Property<int>("DealId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ContractId");
b.HasIndex("DealId");
b.ToTable("DealContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Hearing", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CaseId")
.HasColumnType("integer");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Information")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CaseId");
b.HasIndex("UserId");
b.ToTable("Hearings");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Experience")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Patronymic")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("SpecializationId")
.IsRequired()
.HasColumnType("integer");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("SpecializationId");
b.HasIndex("UserId");
b.ToTable("Lawyers");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.LawyerContract", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ContractId")
.HasColumnType("integer");
b.Property<int>("LawyerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ContractId");
b.HasIndex("LawyerId");
b.ToTable("LawyerContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Specializations");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Login")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Role")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Specialization", "Specialization")
.WithMany("Cases")
.HasForeignKey("SpecializationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Cases")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Specialization");
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseDeal", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case")
.WithMany("Deals")
.HasForeignKey("CaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Deal", "Deal")
.WithMany("CaseDeals")
.HasForeignKey("DealId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Case");
b.Navigation("Deal");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseLawyer", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case")
.WithMany("CaseLawyers")
.HasForeignKey("CaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Lawyer", "Lawyer")
.WithMany("CaseLawyers")
.HasForeignKey("LawyerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Case");
b.Navigation("Lawyer");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Contracts")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Deals")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.DealContract", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Contract", "Contract")
.WithMany("DealContracts")
.HasForeignKey("ContractId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Deal", "Deal")
.WithMany("Contracts")
.HasForeignKey("DealId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Contract");
b.Navigation("Deal");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Hearing", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case")
.WithMany("Hearings")
.HasForeignKey("CaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Hearings")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Case");
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Specialization", "Specialization")
.WithMany("Lawyers")
.HasForeignKey("SpecializationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Lawyers")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Specialization");
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.LawyerContract", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Contract", "Contract")
.WithMany("LawyerContracts")
.HasForeignKey("ContractId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Lawyer", "Lawyer")
.WithMany("LawyerContracts")
.HasForeignKey("LawyerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Contract");
b.Navigation("Lawyer");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Specializations")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b =>
{
b.Navigation("CaseLawyers");
b.Navigation("Deals");
b.Navigation("Hearings");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b =>
{
b.Navigation("DealContracts");
b.Navigation("LawyerContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b =>
{
b.Navigation("CaseDeals");
b.Navigation("Contracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b =>
{
b.Navigation("CaseLawyers");
b.Navigation("LawyerContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b =>
{
b.Navigation("Cases");
b.Navigation("Lawyers");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.User", b =>
{
b.Navigation("Cases");
b.Navigation("Contracts");
b.Navigation("Deals");
b.Navigation("Hearings");
b.Navigation("Lawyers");
b.Navigation("Specializations");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CaseAccountingDataBaseImplement.Migrations
{
/// <inheritdoc />
public partial class migrSpecializationNull : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -0,0 +1,551 @@
// <auto-generated />
using System;
using CaseAccountingDataBaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace CaseAccountingDataBaseImplement.Migrations
{
[DbContext(typeof(CaseAccountingDatabase))]
[Migration("20230519145356_migrSpecializationNullAttempt2")]
partial class migrSpecializationNullAttempt2
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Annotation")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Applicant")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Defendant")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("SpecializationId")
.HasColumnType("integer");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("SpecializationId");
b.HasIndex("UserId");
b.ToTable("Cases");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseDeal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CaseId")
.HasColumnType("integer");
b.Property<int>("DealId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CaseId");
b.HasIndex("DealId");
b.ToTable("CaseDeals");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseLawyer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CaseId")
.HasColumnType("integer");
b.Property<int>("LawyerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CaseId");
b.HasIndex("LawyerId");
b.ToTable("CaseLawyers");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<decimal>("Coast")
.HasColumnType("numeric");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Service")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Contracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Responsibilities")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Subject")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Deals");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.DealContract", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ContractId")
.HasColumnType("integer");
b.Property<int>("DealId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ContractId");
b.HasIndex("DealId");
b.ToTable("DealContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Hearing", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CaseId")
.HasColumnType("integer");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Information")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CaseId");
b.HasIndex("UserId");
b.ToTable("Hearings");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Experience")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Patronymic")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("SpecializationId")
.HasColumnType("integer");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("SpecializationId");
b.HasIndex("UserId");
b.ToTable("Lawyers");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.LawyerContract", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ContractId")
.HasColumnType("integer");
b.Property<int>("LawyerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ContractId");
b.HasIndex("LawyerId");
b.ToTable("LawyerContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Specializations");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Login")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Role")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Specialization", "Specialization")
.WithMany("Cases")
.HasForeignKey("SpecializationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Cases")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Specialization");
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseDeal", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case")
.WithMany("Deals")
.HasForeignKey("CaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Deal", "Deal")
.WithMany("CaseDeals")
.HasForeignKey("DealId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Case");
b.Navigation("Deal");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseLawyer", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case")
.WithMany("CaseLawyers")
.HasForeignKey("CaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Lawyer", "Lawyer")
.WithMany("CaseLawyers")
.HasForeignKey("LawyerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Case");
b.Navigation("Lawyer");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Contracts")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Deals")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.DealContract", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Contract", "Contract")
.WithMany("DealContracts")
.HasForeignKey("ContractId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Deal", "Deal")
.WithMany("Contracts")
.HasForeignKey("DealId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Contract");
b.Navigation("Deal");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Hearing", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case")
.WithMany("Hearings")
.HasForeignKey("CaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Hearings")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Case");
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Specialization", "Specialization")
.WithMany("Lawyers")
.HasForeignKey("SpecializationId");
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Lawyers")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Specialization");
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.LawyerContract", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Contract", "Contract")
.WithMany("LawyerContracts")
.HasForeignKey("ContractId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Lawyer", "Lawyer")
.WithMany("LawyerContracts")
.HasForeignKey("LawyerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Contract");
b.Navigation("Lawyer");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Specializations")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b =>
{
b.Navigation("CaseLawyers");
b.Navigation("Deals");
b.Navigation("Hearings");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b =>
{
b.Navigation("DealContracts");
b.Navigation("LawyerContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b =>
{
b.Navigation("CaseDeals");
b.Navigation("Contracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b =>
{
b.Navigation("CaseLawyers");
b.Navigation("LawyerContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b =>
{
b.Navigation("Cases");
b.Navigation("Lawyers");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.User", b =>
{
b.Navigation("Cases");
b.Navigation("Contracts");
b.Navigation("Deals");
b.Navigation("Hearings");
b.Navigation("Lawyers");
b.Navigation("Specializations");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,59 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CaseAccountingDataBaseImplement.Migrations
{
/// <inheritdoc />
public partial class migrSpecializationNullAttempt2 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Lawyers_Specializations_SpecializationId",
table: "Lawyers");
migrationBuilder.AlterColumn<int>(
name: "SpecializationId",
table: "Lawyers",
type: "integer",
nullable: true,
oldClrType: typeof(int),
oldType: "integer");
migrationBuilder.AddForeignKey(
name: "FK_Lawyers_Specializations_SpecializationId",
table: "Lawyers",
column: "SpecializationId",
principalTable: "Specializations",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Lawyers_Specializations_SpecializationId",
table: "Lawyers");
migrationBuilder.AlterColumn<int>(
name: "SpecializationId",
table: "Lawyers",
type: "integer",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "integer",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "FK_Lawyers_Specializations_SpecializationId",
table: "Lawyers",
column: "SpecializationId",
principalTable: "Specializations",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@ -0,0 +1,551 @@
// <auto-generated />
using System;
using CaseAccountingDataBaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace CaseAccountingDataBaseImplement.Migrations
{
[DbContext(typeof(CaseAccountingDatabase))]
[Migration("20230519162440_migrBindTry1")]
partial class migrBindTry1
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Annotation")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Applicant")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Defendant")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("SpecializationId")
.HasColumnType("integer");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("SpecializationId");
b.HasIndex("UserId");
b.ToTable("Cases");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseDeal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CaseId")
.HasColumnType("integer");
b.Property<int>("DealId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CaseId");
b.HasIndex("DealId");
b.ToTable("CaseDeals");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseLawyer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CaseId")
.HasColumnType("integer");
b.Property<int>("LawyerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CaseId");
b.HasIndex("LawyerId");
b.ToTable("CaseLawyers");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<decimal>("Coast")
.HasColumnType("numeric");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Service")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Contracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Responsibilities")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Subject")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Deals");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.DealContract", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ContractId")
.HasColumnType("integer");
b.Property<int>("DealId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ContractId");
b.HasIndex("DealId");
b.ToTable("DealContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Hearing", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CaseId")
.HasColumnType("integer");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Information")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CaseId");
b.HasIndex("UserId");
b.ToTable("Hearings");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Experience")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Patronymic")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("SpecializationId")
.HasColumnType("integer");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("SpecializationId");
b.HasIndex("UserId");
b.ToTable("Lawyers");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.LawyerContract", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ContractId")
.HasColumnType("integer");
b.Property<int>("LawyerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ContractId");
b.HasIndex("LawyerId");
b.ToTable("LawyerContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Specializations");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Login")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Role")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Specialization", "Specialization")
.WithMany("Cases")
.HasForeignKey("SpecializationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Cases")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Specialization");
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseDeal", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case")
.WithMany("Deals")
.HasForeignKey("CaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Deal", "Deal")
.WithMany("CaseDeals")
.HasForeignKey("DealId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Case");
b.Navigation("Deal");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseLawyer", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case")
.WithMany("CaseLawyers")
.HasForeignKey("CaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Lawyer", "Lawyer")
.WithMany("CaseLawyers")
.HasForeignKey("LawyerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Case");
b.Navigation("Lawyer");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Contracts")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Deals")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.DealContract", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Contract", "Contract")
.WithMany("DealContracts")
.HasForeignKey("ContractId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Deal", "Deal")
.WithMany("Contracts")
.HasForeignKey("DealId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Contract");
b.Navigation("Deal");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Hearing", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case")
.WithMany("Hearings")
.HasForeignKey("CaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Hearings")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Case");
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Specialization", "Specialization")
.WithMany("Lawyers")
.HasForeignKey("SpecializationId");
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Lawyers")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Specialization");
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.LawyerContract", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Contract", "Contract")
.WithMany("LawyerContracts")
.HasForeignKey("ContractId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Lawyer", "Lawyer")
.WithMany("LawyerContracts")
.HasForeignKey("LawyerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Contract");
b.Navigation("Lawyer");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Specializations")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b =>
{
b.Navigation("CaseLawyers");
b.Navigation("Deals");
b.Navigation("Hearings");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b =>
{
b.Navigation("DealContracts");
b.Navigation("LawyerContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b =>
{
b.Navigation("CaseDeals");
b.Navigation("Contracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b =>
{
b.Navigation("CaseLawyers");
b.Navigation("LawyerContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b =>
{
b.Navigation("Cases");
b.Navigation("Lawyers");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.User", b =>
{
b.Navigation("Cases");
b.Navigation("Contracts");
b.Navigation("Deals");
b.Navigation("Hearings");
b.Navigation("Lawyers");
b.Navigation("Specializations");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CaseAccountingDataBaseImplement.Migrations
{
/// <inheritdoc />
public partial class migrBindTry1 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -0,0 +1,551 @@
// <auto-generated />
using System;
using CaseAccountingDataBaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace CaseAccountingDataBaseImplement.Migrations
{
[DbContext(typeof(CaseAccountingDatabase))]
[Migration("20230519172138_migrBindTry2")]
partial class migrBindTry2
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Annotation")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Applicant")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Defendant")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("SpecializationId")
.HasColumnType("integer");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("SpecializationId");
b.HasIndex("UserId");
b.ToTable("Cases");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseDeal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CaseId")
.HasColumnType("integer");
b.Property<int>("DealId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CaseId");
b.HasIndex("DealId");
b.ToTable("CaseDeals");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseLawyer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CaseId")
.HasColumnType("integer");
b.Property<int>("LawyerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CaseId");
b.HasIndex("LawyerId");
b.ToTable("CaseLawyers");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<decimal>("Coast")
.HasColumnType("numeric");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Service")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Contracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Responsibilities")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Subject")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Deals");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.DealContract", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ContractId")
.HasColumnType("integer");
b.Property<int>("DealId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ContractId");
b.HasIndex("DealId");
b.ToTable("DealContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Hearing", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CaseId")
.HasColumnType("integer");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Information")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CaseId");
b.HasIndex("UserId");
b.ToTable("Hearings");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Experience")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Patronymic")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("SpecializationId")
.HasColumnType("integer");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("SpecializationId");
b.HasIndex("UserId");
b.ToTable("Lawyers");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.LawyerContract", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ContractId")
.HasColumnType("integer");
b.Property<int>("LawyerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ContractId");
b.HasIndex("LawyerId");
b.ToTable("LawyerContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Specializations");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Login")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Role")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Specialization", "Specialization")
.WithMany("Cases")
.HasForeignKey("SpecializationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Cases")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Specialization");
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseDeal", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case")
.WithMany("Deals")
.HasForeignKey("CaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Deal", "Deal")
.WithMany("CaseDeals")
.HasForeignKey("DealId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Case");
b.Navigation("Deal");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseLawyer", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case")
.WithMany("CaseLawyers")
.HasForeignKey("CaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Lawyer", "Lawyer")
.WithMany("CaseLawyers")
.HasForeignKey("LawyerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Case");
b.Navigation("Lawyer");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Contracts")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Deals")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.DealContract", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Contract", "Contract")
.WithMany("DealContracts")
.HasForeignKey("ContractId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Deal", "Deal")
.WithMany("Contracts")
.HasForeignKey("DealId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Contract");
b.Navigation("Deal");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Hearing", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case")
.WithMany("Hearings")
.HasForeignKey("CaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Hearings")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Case");
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Specialization", "Specialization")
.WithMany("Lawyers")
.HasForeignKey("SpecializationId");
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Lawyers")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Specialization");
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.LawyerContract", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Contract", "Contract")
.WithMany("LawyerContracts")
.HasForeignKey("ContractId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Lawyer", "Lawyer")
.WithMany("LawyerContracts")
.HasForeignKey("LawyerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Contract");
b.Navigation("Lawyer");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Specializations")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b =>
{
b.Navigation("CaseLawyers");
b.Navigation("Deals");
b.Navigation("Hearings");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b =>
{
b.Navigation("DealContracts");
b.Navigation("LawyerContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b =>
{
b.Navigation("CaseDeals");
b.Navigation("Contracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b =>
{
b.Navigation("CaseLawyers");
b.Navigation("LawyerContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b =>
{
b.Navigation("Cases");
b.Navigation("Lawyers");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.User", b =>
{
b.Navigation("Cases");
b.Navigation("Contracts");
b.Navigation("Deals");
b.Navigation("Hearings");
b.Navigation("Lawyers");
b.Navigation("Specializations");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CaseAccountingDataBaseImplement.Migrations
{
/// <inheritdoc />
public partial class migrBindTry2 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -0,0 +1,551 @@
// <auto-generated />
using System;
using CaseAccountingDataBaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace CaseAccountingDataBaseImplement.Migrations
{
[DbContext(typeof(CaseAccountingDatabase))]
[Migration("20230519222316_migrTilt")]
partial class migrTilt
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Annotation")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Applicant")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Defendant")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("SpecializationId")
.HasColumnType("integer");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("SpecializationId");
b.HasIndex("UserId");
b.ToTable("Cases");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseDeal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CaseId")
.HasColumnType("integer");
b.Property<int>("DealId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CaseId");
b.HasIndex("DealId");
b.ToTable("CaseDeals");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseLawyer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CaseId")
.HasColumnType("integer");
b.Property<int>("LawyerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CaseId");
b.HasIndex("LawyerId");
b.ToTable("CaseLawyers");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<decimal>("Coast")
.HasColumnType("numeric");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Service")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Contracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Responsibilities")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Subject")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Deals");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.DealContract", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ContractId")
.HasColumnType("integer");
b.Property<int>("DealId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ContractId");
b.HasIndex("DealId");
b.ToTable("DealContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Hearing", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CaseId")
.HasColumnType("integer");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Information")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("CaseId");
b.HasIndex("UserId");
b.ToTable("Hearings");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Experience")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Patronymic")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("SpecializationId")
.HasColumnType("integer");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("SpecializationId");
b.HasIndex("UserId");
b.ToTable("Lawyers");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.LawyerContract", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ContractId")
.HasColumnType("integer");
b.Property<int>("LawyerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ContractId");
b.HasIndex("LawyerId");
b.ToTable("LawyerContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Specializations");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Login")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Role")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Specialization", "Specialization")
.WithMany("Cases")
.HasForeignKey("SpecializationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Cases")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Specialization");
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseDeal", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case")
.WithMany("Deals")
.HasForeignKey("CaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Deal", "Deal")
.WithMany("CaseDeals")
.HasForeignKey("DealId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Case");
b.Navigation("Deal");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.CaseLawyer", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case")
.WithMany("CaseLawyers")
.HasForeignKey("CaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Lawyer", "Lawyer")
.WithMany("CaseLawyers")
.HasForeignKey("LawyerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Case");
b.Navigation("Lawyer");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Contracts")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Deals")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.DealContract", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Contract", "Contract")
.WithMany("DealContracts")
.HasForeignKey("ContractId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Deal", "Deal")
.WithMany("Contracts")
.HasForeignKey("DealId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Contract");
b.Navigation("Deal");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Hearing", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Case", "Case")
.WithMany("Hearings")
.HasForeignKey("CaseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Hearings")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Case");
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Specialization", "Specialization")
.WithMany("Lawyers")
.HasForeignKey("SpecializationId");
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Lawyers")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Specialization");
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.LawyerContract", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.Contract", "Contract")
.WithMany("LawyerContracts")
.HasForeignKey("ContractId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.Lawyer", "Lawyer")
.WithMany("LawyerContracts")
.HasForeignKey("LawyerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Contract");
b.Navigation("Lawyer");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b =>
{
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Specializations")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Case", b =>
{
b.Navigation("CaseLawyers");
b.Navigation("Deals");
b.Navigation("Hearings");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Contract", b =>
{
b.Navigation("DealContracts");
b.Navigation("LawyerContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Deal", b =>
{
b.Navigation("CaseDeals");
b.Navigation("Contracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Lawyer", b =>
{
b.Navigation("CaseLawyers");
b.Navigation("LawyerContracts");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.Specialization", b =>
{
b.Navigation("Cases");
b.Navigation("Lawyers");
});
modelBuilder.Entity("CaseAccountingDataBaseImplement.Models.User", b =>
{
b.Navigation("Cases");
b.Navigation("Contracts");
b.Navigation("Deals");
b.Navigation("Hearings");
b.Navigation("Lawyers");
b.Navigation("Specializations");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CaseAccountingDataBaseImplement.Migrations
{
/// <inheritdoc />
public partial class migrTilt : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -239,7 +239,7 @@ namespace CaseAccountingDataBaseImplement.Migrations
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("text");
b.Property<int>("SpecializationId") b.Property<int?>("SpecializationId")
.HasColumnType("integer"); .HasColumnType("integer");
b.Property<string>("Surname") b.Property<string>("Surname")
@ -448,9 +448,7 @@ namespace CaseAccountingDataBaseImplement.Migrations
{ {
b.HasOne("CaseAccountingDataBaseImplement.Models.Specialization", "Specialization") b.HasOne("CaseAccountingDataBaseImplement.Models.Specialization", "Specialization")
.WithMany("Lawyers") .WithMany("Lawyers")
.HasForeignKey("SpecializationId") .HasForeignKey("SpecializationId");
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User") b.HasOne("CaseAccountingDataBaseImplement.Models.User", "User")
.WithMany("Lawyers") .WithMany("Lawyers")

View File

@ -87,15 +87,19 @@ namespace CaseAccountingDataBaseImplement.Models
}; };
} }
public void Update(CaseBindingModel model) public void Update(CaseAccountingDatabase context, CaseBindingModel model)
{ {
if (model == null) if (model == null)
{ {
return; return;
} }
Name = model.Name; Name = model.Name;
Applicant = model.Applicant;
Defendant = model.Defendant;
SpecializationId = model.SpecializationId;
Specialization = context.Specializations.FirstOrDefault(x => x.Id == model.SpecializationId) ?? throw new Exception("Specialization не существует");
Annotation = model.Annotation; Annotation = model.Annotation;
Date = model.Date; Date = DateTime.SpecifyKind(model.Date, DateTimeKind.Utc);
} }
public void UpdateLawyers(CaseAccountingDatabase context, CaseBindingModel model) public void UpdateLawyers(CaseAccountingDatabase context, CaseBindingModel model)
@ -139,6 +143,7 @@ namespace CaseAccountingDataBaseImplement.Models
Annotation = Annotation, Annotation = Annotation,
Date = Date, Date = Date,
SpecializationId = SpecializationId, SpecializationId = SpecializationId,
Specialization = Specialization.Name,
UserId = UserId UserId = UserId
}; };
} }

View File

@ -53,7 +53,7 @@ namespace CaseAccountingDataBaseImplement.Models
} }
} }
public static Contract? Create(ContractBindingModel? model) public static Contract? Create(CaseAccountingDatabase context, ContractBindingModel? model)
{ {
if (model == null) if (model == null)
{ {
@ -65,7 +65,8 @@ namespace CaseAccountingDataBaseImplement.Models
Service = model.Service, Service = model.Service,
Coast = model.Coast, Coast = model.Coast,
Date = model.Date, Date = model.Date,
UserId = model.UserId UserId = model.UserId,
User = context.Users.FirstOrDefault(x => x.Id == model.UserId) ?? throw new Exception("Not found user")
}; };
} }

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