Compare commits
29 Commits
main
...
Task_8_Map
| Author | SHA1 | Date | |
|---|---|---|---|
| 75e352ce26 | |||
| ef4d6f8248 | |||
| f35736a424 | |||
| 7aee0da4ed | |||
| 3736a923c7 | |||
| 29d974f2c1 | |||
| 04966ef9e5 | |||
| eff45b4815 | |||
| 9968b6d69e | |||
| b1a49bfde3 | |||
| 9f03eaa09e | |||
| 1b8b1a06f8 | |||
| fddb9c9d83 | |||
| 5e249e488c | |||
| bd0c52b9f1 | |||
| e1e8d23bd0 | |||
| d3bf4eec43 | |||
| abbfe117f9 | |||
| 8bdc9275d5 | |||
| 65a03714a2 | |||
| 2ee47af951 | |||
| cf45ffb67d | |||
| 9c06125d66 | |||
| fda7d01074 | |||
| 46f94f62b9 | |||
| af9e774126 | |||
| 5a5fc38cb6 | |||
| bca5c116a0 | |||
| 8150c8c96b |
@@ -0,0 +1,70 @@
|
||||
using SmallSoftwareContracts.BusinessLogicsContracts;
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
using SmallSoftwareContracts.StoragesContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SmallSoftwareContracts.Exceptions;
|
||||
using SmallSoftwareContracts.Extensions;
|
||||
using System.Text.Json;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using SmallSoftwareContracts.Resources;
|
||||
|
||||
namespace SmallSoftwareBusinessLogic.Implementations;
|
||||
|
||||
internal class ManufacturerBusinessLogicContract(IManufacturerStorageContract
|
||||
manufacturerStorageContract, IStringLocalizer<Messages> localizer, ILogger logger) : IManufacturerBusinessLogicContract
|
||||
{
|
||||
private readonly ILogger _logger = logger;
|
||||
private readonly IManufacturerStorageContract _manufacturerStorageContract = manufacturerStorageContract;
|
||||
private readonly IStringLocalizer<Messages> _localizer = localizer;
|
||||
public List<ManufacturerDataModel> GetAllManufacturers()
|
||||
{
|
||||
_logger.LogInformation("GetAllManufacturers");
|
||||
return _manufacturerStorageContract.GetList() ?? throw new
|
||||
NullListException();
|
||||
}
|
||||
public ManufacturerDataModel GetManufacturerByData(string data)
|
||||
{
|
||||
_logger.LogInformation("Get element by data: {data}", data);
|
||||
if (data.IsEmpty())
|
||||
{
|
||||
throw new ArgumentNullException(nameof(data));
|
||||
}
|
||||
if (data.IsGuid())
|
||||
{
|
||||
return _manufacturerStorageContract.GetElementById(data) ??
|
||||
throw new ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
return _manufacturerStorageContract.GetElementByName(data) ??
|
||||
_manufacturerStorageContract.GetElementByOldName(data) ??
|
||||
throw new ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
public void InsertManufacturer(ManufacturerDataModel manufacturerDataModel)
|
||||
{
|
||||
_logger.LogInformation("New data: {json}",
|
||||
JsonSerializer.Serialize(manufacturerDataModel));
|
||||
ArgumentNullException.ThrowIfNull(manufacturerDataModel);
|
||||
manufacturerDataModel.Validate(_localizer);
|
||||
_manufacturerStorageContract.AddElement(manufacturerDataModel);
|
||||
}
|
||||
public void UpdateManufacturer(ManufacturerDataModel manufacturerDataModel)
|
||||
{
|
||||
_logger.LogInformation("Update data: {json}",
|
||||
JsonSerializer.Serialize(manufacturerDataModel));
|
||||
ArgumentNullException.ThrowIfNull(manufacturerDataModel);
|
||||
manufacturerDataModel.Validate(_localizer);
|
||||
_manufacturerStorageContract.UpdElement(manufacturerDataModel);
|
||||
}
|
||||
public void DeleteManufacturer(string id)
|
||||
{
|
||||
_logger.LogInformation("Delete by id: {id}", id);
|
||||
if (id.IsEmpty())
|
||||
{
|
||||
throw new ArgumentNullException(nameof(id));
|
||||
}
|
||||
if (!id.IsGuid())
|
||||
{
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
}
|
||||
_manufacturerStorageContract.DelElement(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SmallSoftwareContracts.BusinessLogicsContracts;
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
using SmallSoftwareContracts.Enums;
|
||||
using SmallSoftwareContracts.Exceptions;
|
||||
using SmallSoftwareContracts.Extensions;
|
||||
using SmallSoftwareContracts.Resources;
|
||||
using SmallSoftwareContracts.StoragesContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareBusinessLogic.Implementations;
|
||||
|
||||
internal class PostBusinessLogicContract(IPostStorageContract
|
||||
postStorageContract, IStringLocalizer<Messages> localizer, ILogger logger) : IPostBusinessLogicContract
|
||||
{
|
||||
private readonly ILogger _logger = logger;
|
||||
private readonly IPostStorageContract _postStorageContract =
|
||||
postStorageContract;
|
||||
private readonly IStringLocalizer<Messages> _localizer = localizer;
|
||||
public List<PostDataModel> GetAllPosts()
|
||||
{
|
||||
_logger.LogInformation("GetAllPosts");
|
||||
return _postStorageContract.GetList() ?? throw new NullListException();
|
||||
}
|
||||
public List<PostDataModel> GetAllDataOfPost(string postId)
|
||||
{
|
||||
_logger.LogInformation("GetAllDataOfPost for {postId}", postId);
|
||||
if (postId.IsEmpty())
|
||||
{
|
||||
throw new ArgumentNullException(nameof(postId));
|
||||
}
|
||||
if (!postId.IsGuid())
|
||||
{
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "PostId"));
|
||||
}
|
||||
return _postStorageContract.GetPostWithHistory(postId) ?? throw new
|
||||
NullListException();
|
||||
}
|
||||
public PostDataModel GetPostByData(string data)
|
||||
{
|
||||
_logger.LogInformation("Get element by data: {data}", data);
|
||||
if (data.IsEmpty())
|
||||
{
|
||||
throw new ArgumentNullException(nameof(data));
|
||||
}
|
||||
if (data.IsGuid())
|
||||
{
|
||||
return _postStorageContract.GetElementById(data) ?? throw new
|
||||
ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
return _postStorageContract.GetElementByName(data) ?? throw new
|
||||
ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
public void InsertPost(PostDataModel postDataModel)
|
||||
{
|
||||
_logger.LogInformation("New data: {json}",
|
||||
JsonSerializer.Serialize(postDataModel));
|
||||
ArgumentNullException.ThrowIfNull(postDataModel);
|
||||
postDataModel.Validate(_localizer);
|
||||
_postStorageContract.AddElement(postDataModel);
|
||||
}
|
||||
public void UpdatePost(PostDataModel postDataModel)
|
||||
{
|
||||
_logger.LogInformation("Update data: {json}",
|
||||
JsonSerializer.Serialize(postDataModel));
|
||||
ArgumentNullException.ThrowIfNull(postDataModel);
|
||||
postDataModel.Validate(_localizer);
|
||||
_postStorageContract.UpdElement(postDataModel);
|
||||
}
|
||||
public void DeletePost(string id)
|
||||
{
|
||||
_logger.LogInformation("Delete by id: {id}", id);
|
||||
if (id.IsEmpty())
|
||||
{
|
||||
throw new ArgumentNullException(nameof(id));
|
||||
}
|
||||
if (!id.IsGuid())
|
||||
{
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
}
|
||||
_postStorageContract.DelElement(id);
|
||||
}
|
||||
public void RestorePost(string id)
|
||||
{
|
||||
_logger.LogInformation("Restore by id: {id}", id);
|
||||
if (id.IsEmpty())
|
||||
{
|
||||
throw new ArgumentNullException(nameof(id));
|
||||
}
|
||||
if (!id.IsGuid())
|
||||
{
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
}
|
||||
_postStorageContract.ResElement(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SmallSoftwareBusinessLogic.OfficePackage;
|
||||
using SmallSoftwareContracts.BusinessLogicsContracts;
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
using SmallSoftwareContracts.Exceptions;
|
||||
using SmallSoftwareContracts.Extensions;
|
||||
using SmallSoftwareContracts.Resources;
|
||||
using SmallSoftwareContracts.StoragesContracts;
|
||||
|
||||
namespace SmallSoftwareBusinessLogic.Implementations;
|
||||
|
||||
internal class ReportContract : IReportContract
|
||||
{
|
||||
private readonly ISoftwareStorageContract _softwareStorageContract;
|
||||
private readonly IRequestStorageContract _requestStorageContract;
|
||||
private readonly ISalaryStorageContract _salaryStorageContract;
|
||||
private readonly BaseWordBuilder _baseWordBuilder;
|
||||
private readonly BaseExcelBuilder _baseExcelBuilder;
|
||||
private readonly BasePdfBuilder _basePdfBuilder;
|
||||
private readonly IStringLocalizer<Messages> _localizer ;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
internal readonly string[] tableHeader;
|
||||
internal readonly string[] documentHeader;
|
||||
|
||||
public ReportContract(ISoftwareStorageContract softwareStorageContract,
|
||||
IRequestStorageContract requestStorageContract,
|
||||
ISalaryStorageContract salaryStorageContract,
|
||||
BaseWordBuilder baseWordBuilder,
|
||||
BaseExcelBuilder baseExcelBuilder,
|
||||
BasePdfBuilder basePdfBuilder, IStringLocalizer<Messages> localizer, ILogger logger)
|
||||
{
|
||||
_softwareStorageContract = softwareStorageContract;
|
||||
_requestStorageContract = requestStorageContract;
|
||||
_salaryStorageContract = salaryStorageContract;
|
||||
_baseWordBuilder = baseWordBuilder;
|
||||
_baseExcelBuilder = baseExcelBuilder;
|
||||
_basePdfBuilder = basePdfBuilder;
|
||||
_localizer = localizer;
|
||||
_logger = logger;
|
||||
tableHeader = [_localizer["DocumentExcelCaptionDate"], _localizer["DocumentExcelCaptionSum"], _localizer["DocumentExcelCaptionSoftware"], _localizer["DocumentExcelCaptionCount"]];
|
||||
documentHeader = [_localizer["DocumentDocCaptionSoftware"], _localizer["DocumentDocCaptionOldPrice"], _localizer["DocumentDocCaptionData"]];
|
||||
}
|
||||
|
||||
|
||||
public Task<List<HistoryOfSoftwareDataModel>> GetDataSoftwaresByHistoryAsync(CancellationToken ct)
|
||||
{
|
||||
_logger.LogInformation("Get data SoftwaresByManufacturer");
|
||||
return GetDataBySoftwaresAsync(ct);
|
||||
}
|
||||
private async Task<List<HistoryOfSoftwareDataModel>> GetDataBySoftwaresAsync(CancellationToken ct)
|
||||
=> [.. (await _softwareStorageContract.GetListAsync(ct)).GroupBy(x => x.SoftwareName).Select(x => new HistoryOfSoftwareDataModel {
|
||||
SoftwareName = x.Key, Histories = [.. x.Select(y => y.OldPrice.ToString())], Data = [.. x.Select(y => y.ChangeDate.ToString())] })];
|
||||
|
||||
|
||||
public async Task<Stream> CreateDocumentSoftwaresByHistoryAsync(CancellationToken ct)
|
||||
{
|
||||
_logger.LogInformation("Create report HistoryBySoftware");
|
||||
var data = await GetDataBySoftwaresAsync(ct) ?? throw new InvalidOperationException("No found data");
|
||||
|
||||
var tableData = new List<string[]>
|
||||
{
|
||||
documentHeader
|
||||
};
|
||||
|
||||
foreach (var software in data)
|
||||
{
|
||||
tableData.Add(new string[] { software.SoftwareName, "", "" });
|
||||
|
||||
var pairs = software.Histories.Zip(software.Data,
|
||||
(price, date) => new string[] { "", price, date });
|
||||
|
||||
tableData.AddRange(pairs);
|
||||
}
|
||||
|
||||
return _baseWordBuilder
|
||||
.AddHeader(_localizer["DocumentDocHeader"])
|
||||
.AddParagraph(string.Format(_localizer["DocumentDocSubHeader"], DateTime.Now))
|
||||
.AddTable(
|
||||
widths: new[] { 3000, 3000, 3000 },
|
||||
data: tableData
|
||||
)
|
||||
.Build();
|
||||
}
|
||||
|
||||
public Task<List<RequestDataModel>> GetDataRequestByPeriodAsync(DateTime dateStart, DateTime dateFinish, CancellationToken ct)
|
||||
{
|
||||
_logger.LogInformation("Get data RequestsByPeriod from {dateStart} to {dateFinish}", dateStart, dateFinish);
|
||||
return GetDataByRequestsAsync(dateStart, dateFinish, ct);
|
||||
}
|
||||
|
||||
private async Task<List<RequestDataModel>> GetDataByRequestsAsync(DateTime dateStart, DateTime dateFinish, CancellationToken ct)
|
||||
{
|
||||
if (dateStart.IsDateNotOlder(dateFinish))
|
||||
{
|
||||
throw new IncorrectDatesException(dateStart, dateFinish, _localizer);
|
||||
}
|
||||
return [.. (await _requestStorageContract.GetListAsync(dateStart, dateFinish, ct)).OrderBy(x => x.RequestDate)];
|
||||
}
|
||||
|
||||
public async Task<Stream> CreateDocumentRequestsByPeriodAsync(DateTime dateStart, DateTime dateFinish, CancellationToken ct)
|
||||
{
|
||||
_logger.LogInformation("Create report RequestsByPeriod from {dateStart} to {dateFinish}", dateStart, dateFinish);
|
||||
var data = await GetDataByRequestsAsync(dateStart, dateFinish, ct) ?? throw new InvalidOperationException("No found data");
|
||||
|
||||
var tableHeader = new string[] { "Дата", "Email", "Сумма", "ПО", "Количество" };
|
||||
|
||||
return _baseExcelBuilder
|
||||
.AddHeader(_localizer["DocumentExcelHeader"], 0, 5)
|
||||
.AddParagraph($"c {dateStart.ToShortDateString()} по {dateFinish.ToShortDateString()}", 2)
|
||||
.AddTable(
|
||||
[10, 10, 10, 10, 10],
|
||||
[.. new List<string[]>() { tableHeader }
|
||||
.Union(data.SelectMany(x =>
|
||||
(new List<string[]>() {
|
||||
new string[] {
|
||||
x.RequestDate.ToShortDateString(),
|
||||
x.Email,
|
||||
x.Sum.ToString("N2"),
|
||||
"",
|
||||
""
|
||||
}
|
||||
})
|
||||
.Union(x.Softwares!.Select(y => new string[] {
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
y.SoftwareName,
|
||||
y.Count.ToString("N2")
|
||||
}))
|
||||
.ToArray()
|
||||
)
|
||||
.Union([[
|
||||
_localizer["DocumentExcelCaptionTotal"],
|
||||
"",
|
||||
data.Sum(x => x.Sum).ToString("N2"),
|
||||
"",
|
||||
""
|
||||
]]))
|
||||
])
|
||||
.Build();
|
||||
}
|
||||
|
||||
public Task<List<WorkerSalaryByPeriodDataModel>> GetDataSalaryByPeriodAsync(DateTime dateStart, DateTime dateFinish, CancellationToken ct)
|
||||
{
|
||||
_logger.LogInformation("Get data SalaryByPeriod from {dateStart} to { dateFinish}", dateStart, dateFinish);
|
||||
return GetDataBySalaryAsync(dateStart, dateFinish, ct);
|
||||
}
|
||||
|
||||
private async Task<List<WorkerSalaryByPeriodDataModel>> GetDataBySalaryAsync(DateTime dateStart, DateTime dateFinish, CancellationToken ct)
|
||||
{
|
||||
if (dateStart.IsDateNotOlder(dateFinish))
|
||||
{
|
||||
throw new IncorrectDatesException(dateStart, dateFinish, _localizer);
|
||||
}
|
||||
return [.. (await _salaryStorageContract.GetListAsync(dateStart, dateFinish, ct)).GroupBy(x => x.WorkerFIO).Select(x => new
|
||||
WorkerSalaryByPeriodDataModel { WorkerFIO = x.Key, TotalSalary = x.Sum(y => y.Salary),
|
||||
FromPeriod = x.Min(y => y.SalaryDate), ToPeriod = x.Max(y => y.SalaryDate) }).OrderBy(x => x.WorkerFIO)];
|
||||
}
|
||||
|
||||
public async Task<Stream> CreateDocumentSalaryByPeriodAsync(DateTime dateStart, DateTime dateFinish, CancellationToken ct)
|
||||
{
|
||||
_logger.LogInformation("Create report SalaryByPeriod from {dateStart} to { dateFinish}", dateStart, dateFinish);
|
||||
var data = await GetDataBySalaryAsync(dateStart, dateFinish, ct) ?? throw new InvalidOperationException("No found data");
|
||||
return _basePdfBuilder
|
||||
.AddHeader(_localizer["DocumentPdfHeader"])
|
||||
.AddParagraph(string.Format(_localizer["DocumentPdfSubHeader"], dateStart.ToLocalTime().ToShortDateString(), dateFinish.ToLocalTime().ToShortDateString()))
|
||||
.AddPieChart(_localizer["DocumentPdfDiagramCaption"], [.. data.Select(x => (x.WorkerFIO, x.TotalSalary))]).Build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SmallSoftwareContracts.BusinessLogicsContracts;
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
using SmallSoftwareContracts.Exceptions;
|
||||
using SmallSoftwareContracts.Extensions;
|
||||
using SmallSoftwareContracts.Resources;
|
||||
using SmallSoftwareContracts.StoragesContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareBusinessLogic.Implementations;
|
||||
|
||||
internal class RequestBusinessLogicContract(IRequestStorageContract requestStorageContract, IStringLocalizer<Messages> localizer, ILogger logger) : IRequestBusinessLogicContract
|
||||
{
|
||||
private readonly ILogger _logger = logger;
|
||||
private readonly IRequestStorageContract _requestStorageContract =
|
||||
requestStorageContract;
|
||||
private readonly IStringLocalizer<Messages> _localizer = localizer;
|
||||
public List<RequestDataModel> GetAllRequestsByPeriod(DateTime fromDate, DateTime toDate)
|
||||
{
|
||||
_logger.LogInformation("GetAllRequests params: {fromDate}, {toDate}", fromDate, toDate);
|
||||
if (fromDate.IsDateNotOlder(toDate))
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
return _requestStorageContract.GetList(fromDate, toDate) ?? throw new NullListException();
|
||||
|
||||
}
|
||||
public List<RequestDataModel> GetAllRequestsByWorkerByPeriod(string workerId, DateTime fromDate, DateTime toDate)
|
||||
{
|
||||
_logger.LogInformation("GetAllRequests params: {workerId}, {fromDate}, { toDate} ", workerId, fromDate, toDate);
|
||||
if (fromDate.IsDateNotOlder(toDate))
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
if (workerId.IsEmpty())
|
||||
{
|
||||
throw new ArgumentNullException(nameof(workerId));
|
||||
}
|
||||
if (!workerId.IsGuid())
|
||||
{
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "WorkerId"));
|
||||
}
|
||||
return _requestStorageContract.GetList(fromDate, toDate, workerId:
|
||||
workerId) ?? throw new NullListException();
|
||||
}
|
||||
|
||||
public List<RequestDataModel> GetAllRequestsBySoftwareByPeriod(string softwareId, DateTime fromDate, DateTime toDate)
|
||||
{
|
||||
_logger.LogInformation("GetAllRequests params: {softwareId}, {fromDate}, { toDate} ", softwareId, fromDate, toDate);
|
||||
if (fromDate.IsDateNotOlder(toDate))
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
if (softwareId.IsEmpty())
|
||||
{
|
||||
throw new ArgumentNullException(nameof(softwareId));
|
||||
}
|
||||
if (!softwareId.IsGuid())
|
||||
{
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "SoftwareId"));
|
||||
}
|
||||
return _requestStorageContract.GetList(fromDate, toDate, softwareId:
|
||||
softwareId) ?? throw new NullListException();
|
||||
}
|
||||
|
||||
public RequestDataModel GetRequestByData(string data)
|
||||
{
|
||||
_logger.LogInformation("Get element by data: {data}", data);
|
||||
if (data.IsEmpty())
|
||||
{
|
||||
throw new ArgumentNullException(nameof(data));
|
||||
}
|
||||
if (!data.IsGuid())
|
||||
{
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
}
|
||||
return _requestStorageContract.GetElementById(data) ?? throw new ElementNotFoundException(data, _localizer);
|
||||
|
||||
}
|
||||
public void InsertRequest(RequestDataModel requestDataModel)
|
||||
{
|
||||
_logger.LogInformation("New data: {json}",
|
||||
JsonSerializer.Serialize(requestDataModel));
|
||||
ArgumentNullException.ThrowIfNull(requestDataModel);
|
||||
requestDataModel.Validate(_localizer);
|
||||
_requestStorageContract.AddElement(requestDataModel);
|
||||
|
||||
}
|
||||
public void CancelRequest(string id)
|
||||
{
|
||||
_logger.LogInformation("Cancel by id: {id}", id);
|
||||
if (id.IsEmpty())
|
||||
{
|
||||
throw new ArgumentNullException(nameof(id));
|
||||
}
|
||||
if (!id.IsGuid())
|
||||
{
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
}
|
||||
_requestStorageContract.DelElement(id);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SmallSoftwareContracts.BusinessLogicsContracts;
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
using SmallSoftwareContracts.Exceptions;
|
||||
using SmallSoftwareContracts.Extensions;
|
||||
using SmallSoftwareContracts.Infrastructure;
|
||||
using SmallSoftwareContracts.Infrastructure.PostConfigurations;
|
||||
using SmallSoftwareContracts.Resources;
|
||||
using SmallSoftwareContracts.StoragesContracts;
|
||||
namespace SmallSoftwareBusinessLogic.Implementations;
|
||||
|
||||
|
||||
internal class SalaryBusinessLogicContract(ISalaryStorageContract salaryStorageContract,
|
||||
IRequestStorageContract requestStorageContract, IPostStorageContract postStorageContract,
|
||||
IWorkerStorageContract workerStorageContract, IStringLocalizer<Messages> localizer, ILogger logger, IConfigurationSalary сonfiguration) : ISalaryBusinessLogicContract
|
||||
{
|
||||
private readonly ILogger _logger = logger;
|
||||
private readonly ISalaryStorageContract _salaryStorageContract = salaryStorageContract;
|
||||
private readonly IRequestStorageContract _requestStorageContract = requestStorageContract;
|
||||
private readonly IPostStorageContract _postStorageContract = postStorageContract;
|
||||
private readonly IWorkerStorageContract _workerStorageContract = workerStorageContract;
|
||||
private readonly IConfigurationSalary _salaryConfiguration = сonfiguration;
|
||||
private readonly Lock _lockObject = new();
|
||||
private readonly IStringLocalizer<Messages> _localizer = localizer;
|
||||
public List<SalaryDataModel> GetAllSalariesByPeriod(DateTime fromDate,
|
||||
DateTime toDate)
|
||||
{
|
||||
_logger.LogInformation("GetAllSalaries params: {fromDate}, {toDate}",
|
||||
fromDate, toDate);
|
||||
if (fromDate.IsDateNotOlder(toDate))
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
|
||||
var result = _salaryStorageContract.GetList(fromDate, toDate);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
throw new NullListException();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
public List<SalaryDataModel> GetAllSalariesByPeriodByWorker(DateTime
|
||||
fromDate, DateTime toDate, string workerId)
|
||||
{
|
||||
if (fromDate.IsDateNotOlder(toDate))
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
if (workerId.IsEmpty())
|
||||
{
|
||||
throw new ArgumentNullException(nameof(workerId));
|
||||
}
|
||||
if (!workerId.IsGuid())
|
||||
{
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "WorkerId"));
|
||||
}
|
||||
_logger.LogInformation("GetAllSalaries params: {fromDate}, {toDate}, { workerId} ", fromDate, toDate, workerId);
|
||||
return _salaryStorageContract.GetList(fromDate, toDate, workerId) ??
|
||||
throw new NullListException();
|
||||
}
|
||||
|
||||
|
||||
public void CalculateSalaryByMonth(DateTime date)
|
||||
{
|
||||
_logger.LogInformation("CalculateSalaryByMounth: {date}", date);
|
||||
var startDate = new DateTime(date.Year, date.Month, 1);
|
||||
var finishDate = new DateTime(date.Year, date.Month, DateTime.DaysInMonth(date.Year, date.Month));
|
||||
var workers = _workerStorageContract.GetList() ?? throw new NullListException();
|
||||
foreach (var worker in workers)
|
||||
{
|
||||
var requests = _requestStorageContract.GetList(startDate, finishDate, workerId: worker.Id) ?? throw new NullListException();
|
||||
var post = _postStorageContract.GetElementById(worker.PostId) ??
|
||||
throw new NullListException();
|
||||
var salary = worker.ConfigurationModel switch
|
||||
{
|
||||
null => 0,
|
||||
CashierPostConfiguration cpc => CalculateSalaryForCashier(requests, startDate, finishDate, cpc),
|
||||
SupervisorPostConfiguration spc => CalculateSalaryForSupervisor(startDate, finishDate, spc),
|
||||
PostConfiguration pc => pc.Rate,
|
||||
};
|
||||
_logger.LogDebug("The employee {workerId} was paid a salary of {salary}", worker.Id, salary);
|
||||
_salaryStorageContract.AddElement(new SalaryDataModel(worker.Id, finishDate, salary));
|
||||
}
|
||||
}
|
||||
private double CalculateSalaryForCashier(List<RequestDataModel> requests, DateTime startDate, DateTime finishDate, CashierPostConfiguration config)
|
||||
{
|
||||
var parallelOptions = new ParallelOptions
|
||||
{
|
||||
MaxDegreeOfParallelism = _salaryConfiguration.MaxConcurrentThreads
|
||||
};
|
||||
|
||||
double calcPercent = 0.0;
|
||||
var dates = new List<DateTime>();
|
||||
|
||||
for (var date = startDate; date < finishDate; date = date.AddDays(1))
|
||||
{
|
||||
dates.Add(date);
|
||||
}
|
||||
|
||||
Parallel.ForEach(dates, parallelOptions, date =>
|
||||
{
|
||||
var requestsInDay = requests.Where(x => x.RequestDate >= date && x.RequestDate < date.AddDays(1)).ToArray();
|
||||
if (requestsInDay.Length > 0)
|
||||
{
|
||||
double dailySum = requestsInDay.Sum(x => x.Sum);
|
||||
double dailyAverage = dailySum / requestsInDay.Length;
|
||||
double dailyPercent = dailyAverage * config.SalePercent;
|
||||
|
||||
lock (_lockObject)
|
||||
{
|
||||
calcPercent += dailyPercent;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
double bonus = 0;
|
||||
try
|
||||
{
|
||||
bonus = requests
|
||||
.AsParallel()
|
||||
.WithDegreeOfParallelism(_salaryConfiguration.MaxConcurrentThreads)
|
||||
.Where(x => x.Sum > _salaryConfiguration.ExtraSaleSum)
|
||||
.Sum(x => x.Sum * config.BonusForExtraSales);
|
||||
}
|
||||
catch (AggregateException agEx)
|
||||
{
|
||||
foreach (var ex in agEx.InnerExceptions)
|
||||
{
|
||||
_logger.LogError(ex, "Error calculating bonus in cashier payroll");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
return config.Rate + calcPercent + bonus;
|
||||
}
|
||||
|
||||
private double CalculateSalaryForSupervisor(DateTime startDate, DateTime finishDate, SupervisorPostConfiguration config)
|
||||
{
|
||||
try
|
||||
{
|
||||
return config.Rate + config.PersonalCountTrendPremium *
|
||||
_workerStorageContract.GetWorkerTrend(startDate, finishDate);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error in the supervisor payroll process");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SmallSoftwareContracts.BusinessLogicsContracts;
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
using SmallSoftwareContracts.Enums;
|
||||
using SmallSoftwareContracts.Exceptions;
|
||||
using SmallSoftwareContracts.Extensions;
|
||||
using SmallSoftwareContracts.Resources;
|
||||
using SmallSoftwareContracts.StoragesContracts;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace SmallSoftwareBusinessLogic.Implementations;
|
||||
|
||||
internal class SoftwareBusinessLogicContract(ISoftwareStorageContract
|
||||
softwareStorageContract, IStringLocalizer<Messages> localizer, ILogger logger) : ISoftwareBusinessLogicContract
|
||||
{
|
||||
private readonly ILogger _logger = logger;
|
||||
private readonly ISoftwareStorageContract _softwareStorageContract =
|
||||
softwareStorageContract;
|
||||
private readonly IStringLocalizer<Messages> _localizer = localizer;
|
||||
public List<SoftwareDataModel> GetAllSoftwares(bool onlyActive)
|
||||
{
|
||||
_logger.LogInformation("GetAllSoftwares params: {onlyActive}", onlyActive);
|
||||
return _softwareStorageContract.GetList(onlyActive) ?? throw new
|
||||
NullListException();
|
||||
}
|
||||
public List<SoftwareDataModel> GetAllSoftwaresByManufacturer(string
|
||||
manufacturerId, bool onlyActive = true)
|
||||
{
|
||||
if (manufacturerId.IsEmpty())
|
||||
{
|
||||
throw new ArgumentNullException(nameof(manufacturerId));
|
||||
}
|
||||
if (!manufacturerId.IsGuid())
|
||||
{
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "ManufacturerId"));
|
||||
}
|
||||
_logger.LogInformation("GetAllSoftwares params: {manufacturerId}, { onlyActive} ", manufacturerId, onlyActive);
|
||||
return _softwareStorageContract.GetList(onlyActive, manufacturerId) ??
|
||||
throw new NullListException();
|
||||
}
|
||||
public List<SoftwareHistoryDataModel> GetSoftwareHistoryBySoftware(string softwareId)
|
||||
{
|
||||
_logger.LogInformation("GetSoftwareHistoryBySoftware for {softwareId}", softwareId);
|
||||
if (softwareId.IsEmpty())
|
||||
{
|
||||
throw new ArgumentNullException(nameof(softwareId));
|
||||
}
|
||||
if (!softwareId.IsGuid())
|
||||
{
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "SoftwareId"));
|
||||
}
|
||||
return _softwareStorageContract.GetHistoryBySoftwareId(softwareId) ??
|
||||
throw new NullListException();
|
||||
|
||||
}
|
||||
public SoftwareDataModel GetSoftwareByData(string data)
|
||||
{
|
||||
_logger.LogInformation("Get element by data: {data}", data);
|
||||
if (data.IsEmpty())
|
||||
{
|
||||
throw new ArgumentNullException(nameof(data));
|
||||
}
|
||||
if (data.IsGuid())
|
||||
{
|
||||
return _softwareStorageContract.GetElementById(data) ?? throw
|
||||
new ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
return _softwareStorageContract.GetElementByName(data) ?? throw new
|
||||
ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
public void InsertSoftware(SoftwareDataModel softwareDataModel)
|
||||
{
|
||||
_logger.LogInformation("New data: {json}",
|
||||
JsonSerializer.Serialize(softwareDataModel));
|
||||
ArgumentNullException.ThrowIfNull(softwareDataModel);
|
||||
softwareDataModel.Validate(_localizer);
|
||||
_softwareStorageContract.AddElement(softwareDataModel);
|
||||
}
|
||||
public void UpdateSoftware(SoftwareDataModel softwareDataModel)
|
||||
{
|
||||
_logger.LogInformation("Update data: {json}",
|
||||
JsonSerializer.Serialize(softwareDataModel));
|
||||
ArgumentNullException.ThrowIfNull(softwareDataModel);
|
||||
softwareDataModel.Validate(_localizer);
|
||||
_softwareStorageContract.UpdElement(softwareDataModel);
|
||||
|
||||
}
|
||||
public void DeleteSoftware(string id)
|
||||
{
|
||||
_logger.LogInformation("Delete by id: {id}", id);
|
||||
if (id.IsEmpty())
|
||||
{
|
||||
throw new ArgumentNullException(nameof(id));
|
||||
}
|
||||
if (!id.IsGuid())
|
||||
{
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
}
|
||||
_softwareStorageContract.DelElement(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SmallSoftwareContracts.BusinessLogicsContracts;
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
using SmallSoftwareContracts.Exceptions;
|
||||
using SmallSoftwareContracts.Extensions;
|
||||
using SmallSoftwareContracts.Resources;
|
||||
using SmallSoftwareContracts.StoragesContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareBusinessLogic.Implementations;
|
||||
|
||||
internal class WorkerBusinessLogicContract(IWorkerStorageContract workerStorageContract, IStringLocalizer<Messages> localizer, ILogger logger) : IWorkerBusinessLogicContract
|
||||
{
|
||||
private readonly ILogger _logger = logger;
|
||||
private readonly IWorkerStorageContract _workerStorageContract =
|
||||
workerStorageContract;
|
||||
private readonly IStringLocalizer<Messages> _localizer = localizer;
|
||||
public List<WorkerDataModel> GetAllWorkers(bool onlyActive = true)
|
||||
{
|
||||
_logger.LogInformation("GetAllWorkers params: {onlyActive}",
|
||||
onlyActive);
|
||||
return _workerStorageContract.GetList(onlyActive) ?? throw new
|
||||
NullListException();
|
||||
}
|
||||
public List<WorkerDataModel> GetAllWorkersByPost(string postId, bool
|
||||
onlyActive = true)
|
||||
{
|
||||
_logger.LogInformation("GetAllWorkers params: {postId}, { onlyActive},", postId, onlyActive);
|
||||
if (postId.IsEmpty())
|
||||
{
|
||||
throw new ArgumentNullException(nameof(postId));
|
||||
}
|
||||
if (!postId.IsGuid())
|
||||
{
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "PostId"));
|
||||
}
|
||||
return _workerStorageContract.GetList(onlyActive, postId) ?? throw
|
||||
new NullListException();
|
||||
}
|
||||
public List<WorkerDataModel> GetAllWorkersByBirthDate(DateTime fromDate,
|
||||
DateTime toDate, bool onlyActive = true)
|
||||
{
|
||||
_logger.LogInformation("GetAllWorkers params: {onlyActive}, { fromDate}, { toDate} ", onlyActive, fromDate, toDate);
|
||||
if (fromDate.IsDateNotOlder(toDate))
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
return _workerStorageContract.GetList(onlyActive, fromBirthDate:
|
||||
fromDate, toBirthDate: toDate) ?? throw new NullListException();
|
||||
}
|
||||
public List<WorkerDataModel> GetAllWorkersByEmploymentDate(DateTime
|
||||
fromDate, DateTime toDate, bool onlyActive = true)
|
||||
{
|
||||
_logger.LogInformation("GetAllWorkers params: {onlyActive}, { fromDate}, { toDate} ", onlyActive, fromDate, toDate);
|
||||
if (fromDate.IsDateNotOlder(toDate))
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
return _workerStorageContract.GetList(onlyActive, fromEmploymentDate:
|
||||
fromDate, toEmploymentDate: toDate) ?? throw new NullListException();
|
||||
}
|
||||
public WorkerDataModel GetWorkerByData(string data)
|
||||
{
|
||||
_logger.LogInformation("Get element by data: {data}", data);
|
||||
if (data.IsEmpty())
|
||||
{
|
||||
throw new ArgumentNullException(nameof(data));
|
||||
}
|
||||
if (data.IsGuid())
|
||||
{
|
||||
return _workerStorageContract.GetElementById(data) ?? throw
|
||||
new ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
return _workerStorageContract.GetElementByFIO(data) ?? throw new
|
||||
ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
public void InsertWorker(WorkerDataModel workerDataModel)
|
||||
{
|
||||
_logger.LogInformation("New data: {json}",
|
||||
JsonSerializer.Serialize(workerDataModel));
|
||||
ArgumentNullException.ThrowIfNull(workerDataModel);
|
||||
workerDataModel.Validate(_localizer);
|
||||
_workerStorageContract.AddElement(workerDataModel);
|
||||
}
|
||||
public void UpdateWorker(WorkerDataModel workerDataModel)
|
||||
{
|
||||
_logger.LogInformation("Update data: {json}",
|
||||
JsonSerializer.Serialize(workerDataModel));
|
||||
ArgumentNullException.ThrowIfNull(workerDataModel);
|
||||
workerDataModel.Validate(_localizer);
|
||||
_workerStorageContract.UpdElement(workerDataModel);
|
||||
}
|
||||
public void DeleteWorker(string id)
|
||||
{
|
||||
_logger.LogInformation("Delete by id: {id}", id);
|
||||
if (id.IsEmpty())
|
||||
{
|
||||
throw new ArgumentNullException(nameof(id));
|
||||
}
|
||||
if (!id.IsGuid())
|
||||
{
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
}
|
||||
_workerStorageContract.DelElement(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace SmallSoftwareBusinessLogic.OfficePackage;
|
||||
|
||||
public abstract class BaseExcelBuilder
|
||||
{
|
||||
public abstract BaseExcelBuilder AddHeader(string header, int startIndex, int count);
|
||||
public abstract BaseExcelBuilder AddParagraph(string text, int columnIndex);
|
||||
public abstract BaseExcelBuilder AddTable(int[] columnsWidths, List<string[]> data);
|
||||
public abstract Stream Build();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareBusinessLogic.OfficePackage;
|
||||
|
||||
public abstract class BasePdfBuilder
|
||||
{
|
||||
public abstract BasePdfBuilder AddHeader(string header);
|
||||
public abstract BasePdfBuilder AddParagraph(string text);
|
||||
public abstract BasePdfBuilder AddPieChart(string title, List<(string Caption, double Value)> data);
|
||||
public abstract Stream Build();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace SmallSoftwareBusinessLogic.OfficePackage;
|
||||
public abstract class BaseWordBuilder
|
||||
{
|
||||
public abstract BaseWordBuilder AddHeader(string header);
|
||||
public abstract BaseWordBuilder AddParagraph(string text);
|
||||
public abstract BaseWordBuilder AddTable(int[] widths, List<string[]>
|
||||
data);
|
||||
public abstract Stream Build();
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.DocumentObjectModel.Shapes.Charts;
|
||||
using MigraDoc.Rendering;
|
||||
using System.Text;
|
||||
|
||||
namespace SmallSoftwareBusinessLogic.OfficePackage;
|
||||
|
||||
|
||||
public class MigraDocPdfBuilder : BasePdfBuilder
|
||||
{
|
||||
private readonly Document _document;
|
||||
|
||||
public MigraDocPdfBuilder()
|
||||
{
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
_document = new Document();
|
||||
DefineStyles();
|
||||
}
|
||||
|
||||
public override BasePdfBuilder AddHeader(string header)
|
||||
{
|
||||
_document.AddSection().AddParagraph(header, "NormalBold");
|
||||
return this;
|
||||
}
|
||||
|
||||
public override BasePdfBuilder AddParagraph(string text)
|
||||
{
|
||||
_document.LastSection.AddParagraph(text, "Normal");
|
||||
return this;
|
||||
}
|
||||
|
||||
public override BasePdfBuilder AddPieChart(string title, List<(string Caption, double Value)> data)
|
||||
{
|
||||
if (data == null || data.Count == 0)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
var chart = new Chart(ChartType.Pie2D);
|
||||
var series = chart.SeriesCollection.AddSeries();
|
||||
series.Add(data.Select(x => x.Value).ToArray());
|
||||
var xseries = chart.XValues.AddXSeries();
|
||||
xseries.Add(data.Select(x => x.Caption).ToArray());
|
||||
chart.DataLabel.Type = DataLabelType.Percent;
|
||||
chart.DataLabel.Position = DataLabelPosition.OutsideEnd;
|
||||
chart.Width = Unit.FromCentimeter(16);
|
||||
chart.Height = Unit.FromCentimeter(12);
|
||||
chart.TopArea.AddParagraph(title);
|
||||
chart.XAxis.MajorTickMark = TickMarkType.Outside;
|
||||
chart.YAxis.MajorTickMark = TickMarkType.Outside;
|
||||
chart.YAxis.HasMajorGridlines = true;
|
||||
chart.PlotArea.LineFormat.Width = 1;
|
||||
chart.PlotArea.LineFormat.Visible = true;
|
||||
chart.TopArea.AddLegend();
|
||||
_document.LastSection.Add(chart);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override Stream Build()
|
||||
{
|
||||
var stream = new MemoryStream();
|
||||
var renderer = new PdfDocumentRenderer(true)
|
||||
{
|
||||
Document = _document
|
||||
};
|
||||
renderer.RenderDocument();
|
||||
renderer.PdfDocument.Save(stream);
|
||||
return stream;
|
||||
}
|
||||
|
||||
private void DefineStyles()
|
||||
{
|
||||
var headerStyle = _document.Styles.AddStyle("NormalBold", "Normal");
|
||||
headerStyle.Font.Bold = true;
|
||||
headerStyle.Font.Size = 14;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,308 @@
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using DocumentFormat.OpenXml;
|
||||
|
||||
namespace SmallSoftwareBusinessLogic.OfficePackage;
|
||||
|
||||
public class OpenXmlExcelBuilder : BaseExcelBuilder
|
||||
{
|
||||
private readonly SheetData _sheetData;
|
||||
private readonly MergeCells _mergeCells;
|
||||
private readonly Columns _columns;
|
||||
private uint _rowIndex = 0;
|
||||
|
||||
public OpenXmlExcelBuilder()
|
||||
{
|
||||
_sheetData = new SheetData();
|
||||
_mergeCells = new MergeCells();
|
||||
_columns = new Columns();
|
||||
_rowIndex = 1;
|
||||
}
|
||||
|
||||
public override BaseExcelBuilder AddHeader(string header, int startIndex, int count)
|
||||
{
|
||||
CreateCell(startIndex, _rowIndex, header, StyleIndex.BoldTextWithBorders);
|
||||
for (int i = startIndex + 1; i < startIndex + count; ++i)
|
||||
{
|
||||
CreateCell(i, _rowIndex, "", StyleIndex.BoldTextWithBorders);
|
||||
}
|
||||
_mergeCells.Append(new MergeCell()
|
||||
{
|
||||
Reference = new StringValue($"{GetExcelColumnName(startIndex)}{_rowIndex}:{GetExcelColumnName(startIndex + count - 1)}{_rowIndex}")
|
||||
});
|
||||
_rowIndex++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public override BaseExcelBuilder AddParagraph(string text, int columnIndex)
|
||||
{
|
||||
CreateCell(columnIndex, _rowIndex++, text, StyleIndex.SimpleTextWithoutBorder);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override BaseExcelBuilder AddTable(int[] columnsWidths, List<string[]> data)
|
||||
{
|
||||
if (columnsWidths == null || columnsWidths.Length == 0)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(columnsWidths));
|
||||
}
|
||||
if (data == null || data.Count == 0)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(data));
|
||||
}
|
||||
if (data.Any(x => x.Length != columnsWidths.Length))
|
||||
{
|
||||
throw new InvalidOperationException("widths.Length != data.Length");
|
||||
}
|
||||
|
||||
uint counter = 1;
|
||||
int coef = 2;
|
||||
_columns.Append(columnsWidths.Select(x => new Column
|
||||
{
|
||||
Min = counter,
|
||||
Max = counter++,
|
||||
Width = x * coef,
|
||||
CustomWidth = true
|
||||
}));
|
||||
|
||||
for (var j = 0; j < data.First().Length; ++j)
|
||||
{
|
||||
CreateCell(j, _rowIndex, data.First()[j], StyleIndex.BoldTextWithBorders);
|
||||
}
|
||||
_rowIndex++;
|
||||
|
||||
for (var i = 1; i < data.Count - 1; ++i)
|
||||
{
|
||||
for (var j = 0; j < data[i].Length; ++j)
|
||||
{
|
||||
CreateCell(j, _rowIndex, data[i][j], StyleIndex.SimpleTextWithBorders);
|
||||
}
|
||||
_rowIndex++;
|
||||
}
|
||||
|
||||
for (var j = 0; j < data.Last().Length; ++j)
|
||||
{
|
||||
CreateCell(j, _rowIndex, data.Last()[j], StyleIndex.BoldTextWithBorders);
|
||||
}
|
||||
_rowIndex++;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public override Stream Build()
|
||||
{
|
||||
var stream = new MemoryStream();
|
||||
using var spreadsheetDocument = SpreadsheetDocument.Create(stream,
|
||||
SpreadsheetDocumentType.Workbook);
|
||||
var workbookpart = spreadsheetDocument.AddWorkbookPart();
|
||||
GenerateStyle(workbookpart);
|
||||
workbookpart.Workbook = new Workbook();
|
||||
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
||||
worksheetPart.Worksheet = new Worksheet();
|
||||
if (_columns.HasChildren)
|
||||
{
|
||||
worksheetPart.Worksheet.Append(_columns);
|
||||
}
|
||||
worksheetPart.Worksheet.Append(_sheetData);
|
||||
var sheets =
|
||||
spreadsheetDocument.WorkbookPart!.Workbook.AppendChild(new Sheets());
|
||||
var sheet = new Sheet()
|
||||
{
|
||||
Id =
|
||||
spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
|
||||
SheetId = 1,
|
||||
Name = "Лист 1"
|
||||
};
|
||||
sheets.Append(sheet);
|
||||
if (_mergeCells.HasChildren)
|
||||
{
|
||||
worksheetPart.Worksheet.InsertAfter(_mergeCells,
|
||||
worksheetPart.Worksheet.Elements<SheetData>().First());
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
private static void GenerateStyle(WorkbookPart workbookPart)
|
||||
{
|
||||
var workbookStylesPart = workbookPart.AddNewPart<WorkbookStylesPart>();
|
||||
workbookStylesPart.Stylesheet = new Stylesheet();
|
||||
|
||||
var fonts = new Fonts()
|
||||
{
|
||||
Count = 2,
|
||||
KnownFonts = BooleanValue.FromBoolean(true)
|
||||
};
|
||||
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
|
||||
{
|
||||
FontSize = new FontSize() { Val = 11 },
|
||||
FontName = new FontName() { Val = "Calibri" },
|
||||
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
|
||||
FontScheme = new FontScheme()
|
||||
{
|
||||
Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor)
|
||||
}
|
||||
});
|
||||
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
|
||||
{
|
||||
FontSize = new FontSize() { Val = 11 },
|
||||
FontName = new FontName() { Val = "Calibri" },
|
||||
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
|
||||
FontScheme = new FontScheme()
|
||||
{
|
||||
Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor)
|
||||
},
|
||||
Bold = new Bold()
|
||||
});
|
||||
|
||||
workbookStylesPart.Stylesheet.Append(fonts);
|
||||
|
||||
var fills = new Fills() { Count = 1 };
|
||||
fills.Append(new Fill
|
||||
{
|
||||
PatternFill = new PatternFill()
|
||||
{
|
||||
PatternType = new EnumValue<PatternValues>(PatternValues.None)
|
||||
}
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(fills);
|
||||
|
||||
var borders = new Borders() { Count = 2 };
|
||||
borders.Append(new Border
|
||||
{
|
||||
LeftBorder = new LeftBorder(),
|
||||
RightBorder = new RightBorder(),
|
||||
TopBorder = new TopBorder(),
|
||||
BottomBorder = new BottomBorder(),
|
||||
DiagonalBorder = new DiagonalBorder()
|
||||
});
|
||||
borders.Append(new Border
|
||||
{
|
||||
LeftBorder = new LeftBorder() { Style = BorderStyleValues.Thin },
|
||||
RightBorder = new RightBorder() { Style = BorderStyleValues.Thin },
|
||||
TopBorder = new TopBorder() { Style = BorderStyleValues.Thin },
|
||||
BottomBorder = new BottomBorder() { Style = BorderStyleValues.Thin },
|
||||
DiagonalBorder = new DiagonalBorder()
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(borders);
|
||||
var cellFormats = new CellFormats() { Count = 4 };
|
||||
cellFormats.Append(new CellFormat
|
||||
{
|
||||
NumberFormatId = 0,
|
||||
FormatId = 0,
|
||||
FontId = 0,
|
||||
BorderId = 0,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Horizontal = HorizontalAlignmentValues.Left,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
cellFormats.Append(new CellFormat
|
||||
{
|
||||
NumberFormatId = 0,
|
||||
FormatId = 0,
|
||||
FontId = 0,
|
||||
BorderId = 1,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Horizontal = HorizontalAlignmentValues.Left,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
cellFormats.Append(new CellFormat
|
||||
{
|
||||
NumberFormatId = 0,
|
||||
FormatId = 0,
|
||||
FontId = 1,
|
||||
BorderId = 0,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Horizontal = HorizontalAlignmentValues.Left,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
cellFormats.Append(new CellFormat
|
||||
{
|
||||
NumberFormatId = 0,
|
||||
FormatId = 0,
|
||||
FontId = 1,
|
||||
BorderId = 1,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Horizontal = HorizontalAlignmentValues.Left,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(cellFormats);
|
||||
}
|
||||
|
||||
private enum StyleIndex
|
||||
{
|
||||
SimpleTextWithoutBorder = 0,
|
||||
SimpleTextWithBorders = 1,
|
||||
BoldTextWithoutBorders = 2,
|
||||
BoldTextWithBorders = 3
|
||||
}
|
||||
|
||||
private void CreateCell(int columnIndex, uint rowIndex, string text, StyleIndex styleIndex)
|
||||
{
|
||||
var columnName = GetExcelColumnName(columnIndex);
|
||||
var cellReference = columnName + rowIndex;
|
||||
var row = _sheetData.Elements<Row>().FirstOrDefault(r => r.RowIndex == rowIndex);
|
||||
if (row == null)
|
||||
{
|
||||
row = new Row() { RowIndex = rowIndex };
|
||||
_sheetData.Append(row);
|
||||
}
|
||||
|
||||
var newCell = row.Elements<Cell>()
|
||||
.FirstOrDefault(c => c.CellReference != null && c.CellReference.Value == columnName + rowIndex);
|
||||
if (newCell == null)
|
||||
{
|
||||
Cell? refCell = null;
|
||||
foreach (Cell cell in row.Elements<Cell>())
|
||||
{
|
||||
if (cell.CellReference?.Value != null && cell.CellReference.Value.Length == cellReference.Length)
|
||||
{
|
||||
if (string.Compare(cell.CellReference.Value, cellReference, true) > 0)
|
||||
{
|
||||
refCell = cell;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
newCell = new Cell() { CellReference = cellReference };
|
||||
row.InsertBefore(newCell, refCell);
|
||||
}
|
||||
|
||||
newCell.CellValue = new CellValue(text);
|
||||
newCell.DataType = CellValues.String;
|
||||
newCell.StyleIndex = (uint)styleIndex;
|
||||
}
|
||||
|
||||
private static string GetExcelColumnName(int columnNumber)
|
||||
{
|
||||
columnNumber += 1;
|
||||
int dividend = columnNumber;
|
||||
string columnName = string.Empty;
|
||||
int modulo;
|
||||
|
||||
while (dividend > 0)
|
||||
{
|
||||
modulo = (dividend - 1) % 26;
|
||||
columnName = Convert.ToChar(65 + modulo).ToString() + columnName;
|
||||
dividend = (dividend - modulo) / 26;
|
||||
}
|
||||
|
||||
return columnName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
|
||||
namespace SmallSoftwareBusinessLogic.OfficePackage;
|
||||
|
||||
public class OpenXmlWordBuilder : BaseWordBuilder
|
||||
{
|
||||
private readonly Document _document;
|
||||
private readonly Body _body;
|
||||
|
||||
public OpenXmlWordBuilder()
|
||||
{
|
||||
;
|
||||
_document = new Document();
|
||||
_body = _document.AppendChild(new Body());
|
||||
}
|
||||
|
||||
public override BaseWordBuilder AddHeader(string header)
|
||||
{
|
||||
var paragraph = _body.AppendChild(new Paragraph());
|
||||
var run = paragraph.AppendChild(new Run());
|
||||
|
||||
var runProperties = new RunProperties();
|
||||
runProperties.AppendChild(new Bold());
|
||||
run.AppendChild(runProperties);
|
||||
|
||||
run.AppendChild(new Text(header));
|
||||
return this;
|
||||
}
|
||||
|
||||
public override BaseWordBuilder AddParagraph(string text)
|
||||
{
|
||||
var paragraph = _body.AppendChild(new Paragraph());
|
||||
var run = paragraph.AppendChild(new Run());
|
||||
run.AppendChild(new Text(text));
|
||||
return this;
|
||||
}
|
||||
|
||||
public override BaseWordBuilder AddTable(int[] widths, List<string[]> data)
|
||||
{
|
||||
if (widths == null || widths.Length == 0)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(widths));
|
||||
}
|
||||
if (data == null || data.Count == 0)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(data));
|
||||
}
|
||||
if (data.Any(x => x.Length != widths.Length))
|
||||
{
|
||||
throw new InvalidOperationException("widths.Length != data.Length");
|
||||
}
|
||||
var table = new Table();
|
||||
table.AppendChild(new TableProperties(
|
||||
new TableBorders(
|
||||
new TopBorder()
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new BottomBorder()
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new LeftBorder()
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new RightBorder()
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new InsideHorizontalBorder()
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new InsideVerticalBorder()
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
}
|
||||
)
|
||||
));
|
||||
var tr = new TableRow();
|
||||
for (var j = 0; j < widths.Length; ++j)
|
||||
{
|
||||
tr.Append(new TableCell(
|
||||
new TableCellProperties(new TableCellWidth()
|
||||
{
|
||||
Width =
|
||||
widths[j].ToString()
|
||||
}),
|
||||
new Paragraph(new Run(new RunProperties(new Bold()), new Text(data.First()[j])))));
|
||||
}
|
||||
table.Append(tr);
|
||||
table.Append(data.Skip(1).Select(x =>
|
||||
new TableRow(x.Select(y => new TableCell(new Paragraph(new
|
||||
Run(new Text(y))))))));
|
||||
_body.Append(table);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override Stream Build()
|
||||
{
|
||||
var stream = new MemoryStream();
|
||||
using var wordDocument = WordprocessingDocument.Create(stream, WordprocessingDocumentType.Document);
|
||||
var mainPart = wordDocument.AddMainDocumentPart();
|
||||
mainPart.Document = _document;
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="3.3.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.2" />
|
||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<InternalsVisibleTo Include="SmallSoftwareTests" />
|
||||
<InternalsVisibleTo Include="SmallSoftwareWebApi" />
|
||||
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SmallSoftwareContracts\SmallSoftwareContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,18 @@
|
||||
using SmallSoftwareContracts.AdapterContracts.OperationResponses;
|
||||
using SmallSoftwareContracts.BindingModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareContracts.AdapterContracts;
|
||||
|
||||
public interface IManufacturerAdapter
|
||||
{
|
||||
ManufacturerOperationResponse GetList();
|
||||
ManufacturerOperationResponse GetElement(string data);
|
||||
ManufacturerOperationResponse RegisterManufacturer(ManufacturerBindingModel manufacturerModel);
|
||||
ManufacturerOperationResponse ChangeManufacturerInfo(ManufacturerBindingModel manufacturerModel);
|
||||
ManufacturerOperationResponse RemoveManufacturer(string id);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using SmallSoftwareContracts.AdapterContracts.OperationResponses;
|
||||
using SmallSoftwareContracts.BindingModels;
|
||||
|
||||
namespace SmallSoftwareContracts.AdapterContracts;
|
||||
|
||||
public interface IPostAdapter
|
||||
{
|
||||
PostOperationResponse GetList();
|
||||
PostOperationResponse GetHistory(string id);
|
||||
PostOperationResponse GetElement(string data);
|
||||
PostOperationResponse RegisterPost(PostBindingModel postModel);
|
||||
PostOperationResponse ChangePostInfo(PostBindingModel postModel);
|
||||
PostOperationResponse RemovePost(string id);
|
||||
PostOperationResponse RestorePost(string id);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using SmallSoftwareContracts.AdapterContracts.OperationResponses;
|
||||
|
||||
namespace SmallSoftwareContracts.AdapterContracts;
|
||||
|
||||
public interface IReportAdapter
|
||||
{
|
||||
Task<ReportOperationResponse> GetDataSoftwaresByHistoryAsync(CancellationToken ct);
|
||||
Task<ReportOperationResponse> CreateDocumentSoftwaresByHistoryAsync(CancellationToken ct);
|
||||
Task<ReportOperationResponse> GetDataRequestByPeriodAsync(DateTime dateStart, DateTime dateFinish, CancellationToken ct);
|
||||
Task<ReportOperationResponse> CreateDocumentRequestsByPeriodAsync(DateTime dateStart, DateTime dateFinish, CancellationToken ct);
|
||||
Task<ReportOperationResponse> GetDataSalaryByPeriodAsync(DateTime dateStart, DateTime dateFinish, CancellationToken ct);
|
||||
Task<ReportOperationResponse> CreateDocumentSalaryByPeriodAsync(DateTime dateStart, DateTime dateFinish, CancellationToken ct);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using SmallSoftwareContracts.AdapterContracts.OperationResponses;
|
||||
using SmallSoftwareContracts.BindingModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareContracts.AdapterContracts;
|
||||
|
||||
public interface IRequestAdapter
|
||||
{
|
||||
|
||||
RequestOperationResponse GetList(DateTime fromDate, DateTime toDate);
|
||||
RequestOperationResponse GetWorkerList(string id, DateTime fromDate, DateTime
|
||||
toDate);
|
||||
RequestOperationResponse GetSoftwareList(string id, DateTime fromDate, DateTime
|
||||
toDate);
|
||||
RequestOperationResponse GetElement(string id);
|
||||
RequestOperationResponse MakeRequest(RequestBindingModel saleModel);
|
||||
RequestOperationResponse CancelRequest(string id);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using SmallSoftwareContracts.AdapterContracts.OperationResponses;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareContracts.AdapterContracts;
|
||||
|
||||
public interface ISalaryAdapter
|
||||
{
|
||||
SalaryOperationResponse GetListByPeriod(DateTime fromDate, DateTime toDate);
|
||||
SalaryOperationResponse GetListByPeriodByWorker(DateTime fromDate, DateTime toDate, string workerId);
|
||||
SalaryOperationResponse CalculateSalary(DateTime date);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using SmallSoftwareContracts.AdapterContracts.OperationResponses;
|
||||
using SmallSoftwareContracts.BindingModels;
|
||||
|
||||
namespace SmallSoftwareContracts.AdapterContracts;
|
||||
|
||||
public interface ISoftwareAdapter
|
||||
{
|
||||
SoftwareOperationResponse GetList(bool includeDeleted);
|
||||
SoftwareOperationResponse GetManufacturerList(string id, bool
|
||||
includeDeleted);
|
||||
SoftwareOperationResponse GetHistory(string id);
|
||||
SoftwareOperationResponse GetElement(string data);
|
||||
SoftwareOperationResponse RegisterSoftware(SoftwareBindingModel productModel);
|
||||
SoftwareOperationResponse ChangeSoftwareInfo(SoftwareBindingModel
|
||||
productModel);
|
||||
SoftwareOperationResponse RemoveSoftware(string id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using SmallSoftwareContracts.AdapterContracts.OperationResponses;
|
||||
using SmallSoftwareContracts.BindingModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareContracts.AdapterContracts;
|
||||
|
||||
public interface IWorkerAdapter
|
||||
{
|
||||
WorkerOperationResponse GetList(bool includeDeleted);
|
||||
WorkerOperationResponse GetPostList(string id, bool includeDeleted);
|
||||
WorkerOperationResponse GetListByBirthDate(DateTime fromDate, DateTime toDate, bool includeDeleted);
|
||||
WorkerOperationResponse GetListByEmploymentDate(DateTime fromDate, DateTime
|
||||
toDate, bool includeDeleted);
|
||||
WorkerOperationResponse GetElement(string data);
|
||||
WorkerOperationResponse RegisterWorker(WorkerBindingModel workerModel);
|
||||
WorkerOperationResponse ChangeWorkerInfo(WorkerBindingModel workerModel);
|
||||
WorkerOperationResponse RemoveWorker(string id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using SmallSoftwareContracts.Infrastructure;
|
||||
using SmallSoftwareContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareContracts.AdapterContracts.OperationResponses;
|
||||
|
||||
public class ManufacturerOperationResponse : OperationResponse
|
||||
{
|
||||
public static ManufacturerOperationResponse OK(List<ManufacturerViewModel>
|
||||
data) => OK<ManufacturerOperationResponse, List<ManufacturerViewModel>>(data);
|
||||
public static ManufacturerOperationResponse OK(ManufacturerViewModel data)
|
||||
=> OK<ManufacturerOperationResponse, ManufacturerViewModel>(data);
|
||||
public static ManufacturerOperationResponse NoContent() =>
|
||||
NoContent<ManufacturerOperationResponse>();
|
||||
public static ManufacturerOperationResponse NotFound(string message) =>
|
||||
NotFound<ManufacturerOperationResponse>(message);
|
||||
public static ManufacturerOperationResponse BadRequest(string message) =>
|
||||
BadRequest<ManufacturerOperationResponse>(message);
|
||||
public static ManufacturerOperationResponse InternalServerError(string
|
||||
message) => InternalServerError<ManufacturerOperationResponse>(message);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using SmallSoftwareContracts.Infrastructure;
|
||||
using SmallSoftwareContracts.ViewModels;
|
||||
|
||||
namespace SmallSoftwareContracts.AdapterContracts.OperationResponses;
|
||||
|
||||
public class PostOperationResponse : OperationResponse
|
||||
{
|
||||
public static PostOperationResponse OK(List<PostViewModel> data) =>
|
||||
OK<PostOperationResponse, List<PostViewModel>>(data);
|
||||
public static PostOperationResponse OK(PostViewModel data) =>
|
||||
OK<PostOperationResponse, PostViewModel>(data);
|
||||
public static PostOperationResponse NoContent() =>
|
||||
NoContent<PostOperationResponse>();
|
||||
public static PostOperationResponse NotFound(string message) =>
|
||||
NotFound<PostOperationResponse>(message);
|
||||
public static PostOperationResponse BadRequest(string message) =>
|
||||
BadRequest<PostOperationResponse>(message);
|
||||
public static PostOperationResponse InternalServerError(string message) =>
|
||||
InternalServerError<PostOperationResponse>(message);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
using SmallSoftwareContracts.Infrastructure;
|
||||
using SmallSoftwareContracts.ViewModels;
|
||||
|
||||
namespace SmallSoftwareContracts.AdapterContracts.OperationResponses;
|
||||
|
||||
public class ReportOperationResponse : OperationResponse
|
||||
{
|
||||
public static ReportOperationResponse OK(List<HistoryOfSoftwareViewModel> data) => OK<ReportOperationResponse, List<HistoryOfSoftwareViewModel>>(data);
|
||||
public static ReportOperationResponse OK(List<RequestViewModel> data) => OK<ReportOperationResponse, List<RequestViewModel>>(data);
|
||||
public static ReportOperationResponse OK(Stream data, string filename) => OK<ReportOperationResponse, Stream>(data, filename);
|
||||
public static ReportOperationResponse BadRequest(string message) => BadRequest<ReportOperationResponse>(message);
|
||||
public static ReportOperationResponse InternalServerError(string message) => InternalServerError<ReportOperationResponse>(message);
|
||||
public static ReportOperationResponse OK(List<WorkerSalaryByPeriodViewModel> data) => OK<ReportOperationResponse, List<WorkerSalaryByPeriodViewModel>>(data);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using SmallSoftwareContracts.Infrastructure;
|
||||
using SmallSoftwareContracts.ViewModels;
|
||||
|
||||
namespace SmallSoftwareContracts.AdapterContracts.OperationResponses;
|
||||
public class RequestOperationResponse : OperationResponse
|
||||
{
|
||||
public static RequestOperationResponse OK(List<RequestViewModel> data) =>
|
||||
OK<RequestOperationResponse, List<RequestViewModel>>(data);
|
||||
public static RequestOperationResponse OK(RequestViewModel data) =>
|
||||
OK<RequestOperationResponse, RequestViewModel>(data);
|
||||
public static RequestOperationResponse NoContent() =>
|
||||
NoContent<RequestOperationResponse>();
|
||||
public static RequestOperationResponse NotFound(string message) =>
|
||||
NotFound<RequestOperationResponse>(message);
|
||||
public static RequestOperationResponse BadRequest(string message) =>
|
||||
BadRequest<RequestOperationResponse>(message);
|
||||
public static RequestOperationResponse InternalServerError(string message) =>
|
||||
InternalServerError<RequestOperationResponse>(message);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using SmallSoftwareContracts.Infrastructure;
|
||||
using SmallSoftwareContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareContracts.AdapterContracts.OperationResponses;
|
||||
|
||||
public class SalaryOperationResponse : OperationResponse
|
||||
{
|
||||
public static SalaryOperationResponse OK(List<SalaryViewModel> data) => OK<SalaryOperationResponse, List<SalaryViewModel>>(data);
|
||||
public static SalaryOperationResponse NoContent() => NoContent<SalaryOperationResponse>();
|
||||
public static SalaryOperationResponse NotFound(string message) => NotFound<SalaryOperationResponse>(message);
|
||||
public static SalaryOperationResponse BadRequest(string message) => BadRequest<SalaryOperationResponse>(message);
|
||||
public static SalaryOperationResponse InternalServerError(string message) => InternalServerError<SalaryOperationResponse>(message);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using SmallSoftwareContracts.Infrastructure;
|
||||
using SmallSoftwareContracts.ViewModels;
|
||||
|
||||
namespace SmallSoftwareContracts.AdapterContracts.OperationResponses;
|
||||
|
||||
public class SoftwareOperationResponse : OperationResponse
|
||||
{
|
||||
public static SoftwareOperationResponse OK(List<SoftwareViewModel> data) =>
|
||||
OK<SoftwareOperationResponse, List<SoftwareViewModel>>(data);
|
||||
public static SoftwareOperationResponse OK(List<SoftwareHistoryViewModel>
|
||||
data) => OK<SoftwareOperationResponse, List<SoftwareHistoryViewModel>>(data);
|
||||
public static SoftwareOperationResponse OK(SoftwareViewModel data) =>
|
||||
OK<SoftwareOperationResponse, SoftwareViewModel>(data);
|
||||
public static SoftwareOperationResponse NoContent() =>
|
||||
NoContent<SoftwareOperationResponse>();
|
||||
public static SoftwareOperationResponse NotFound(string message) =>
|
||||
NotFound<SoftwareOperationResponse>(message);
|
||||
public static SoftwareOperationResponse BadRequest(string message) =>
|
||||
BadRequest<SoftwareOperationResponse>(message);
|
||||
public static SoftwareOperationResponse InternalServerError(string message)
|
||||
=> InternalServerError<SoftwareOperationResponse>(message);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using SmallSoftwareContracts.Infrastructure;
|
||||
using SmallSoftwareContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareContracts.AdapterContracts.OperationResponses;
|
||||
public class WorkerOperationResponse : OperationResponse
|
||||
{
|
||||
public static WorkerOperationResponse OK(List<WorkerViewModel> data) =>
|
||||
OK<WorkerOperationResponse, List<WorkerViewModel>>(data);
|
||||
public static WorkerOperationResponse OK(WorkerViewModel data) =>
|
||||
OK<WorkerOperationResponse, WorkerViewModel>(data);
|
||||
public static WorkerOperationResponse NoContent() =>
|
||||
NoContent<WorkerOperationResponse>();
|
||||
public static WorkerOperationResponse NotFound(string message) =>
|
||||
NotFound<WorkerOperationResponse>(message);
|
||||
public static WorkerOperationResponse BadRequest(string message) =>
|
||||
BadRequest<WorkerOperationResponse>(message);
|
||||
public static WorkerOperationResponse InternalServerError(string message)
|
||||
=> InternalServerError<WorkerOperationResponse>(message);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace SmallSoftwareContracts.BindingModels;
|
||||
|
||||
public class InstallationRequestBindingModel
|
||||
|
||||
{
|
||||
|
||||
public string? SoftwareId { get; set; }
|
||||
public string? RequestId { get; set; }
|
||||
public int Count { get; set; }
|
||||
public double Price { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareContracts.BindingModels;
|
||||
|
||||
public class ManufacturerBindingModel
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public string? ManufacturerName { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareContracts.BindingModels;
|
||||
|
||||
public class PostBindingModel
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public string? PostId => Id;
|
||||
public string? PostName { get; set; }
|
||||
public string? PostType { get; set; }
|
||||
public double? Salary { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
|
||||
namespace SmallSoftwareContracts.BindingModels;
|
||||
|
||||
public class RequestBindingModel
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public string? WorkerId { get; set; }
|
||||
public List<InstallationRequestBindingModel>? Softwares { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using SmallSoftwareContracts.Enums;
|
||||
|
||||
namespace SmallSoftwareContracts.BindingModels;
|
||||
|
||||
public class SoftwareBindingModel
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public string? SoftwareName { get; set; }
|
||||
public string? SoftwareType { get; set; }
|
||||
public string? ManufacturerId { get; set; }
|
||||
public double Price { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareContracts.BindingModels;
|
||||
public class WorkerBindingModel
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public string? FIO { get; set; }
|
||||
public string? PostId { get; set; }
|
||||
public DateTime BirthDate { get; set; }
|
||||
public DateTime EmploymentDate { get; set; }
|
||||
public string? ConfigurationJson { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareContracts.BusinessLogicsContracts;
|
||||
|
||||
internal interface IManufacturerBusinessLogicContract
|
||||
{
|
||||
List<ManufacturerDataModel> GetAllManufacturers();
|
||||
ManufacturerDataModel GetManufacturerByData(string data);
|
||||
void InsertManufacturer(ManufacturerDataModel manufacturerDataModel);
|
||||
void UpdateManufacturer(ManufacturerDataModel manufacturerDataModel);
|
||||
void DeleteManufacturer(string id);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareContracts.BusinessLogicsContracts;
|
||||
|
||||
internal interface IPostBusinessLogicContract
|
||||
{
|
||||
List<PostDataModel> GetAllPosts();
|
||||
List<PostDataModel> GetAllDataOfPost(string postId);
|
||||
PostDataModel GetPostByData(string data);
|
||||
void InsertPost(PostDataModel postDataModel);
|
||||
void UpdatePost(PostDataModel postDataModel);
|
||||
void DeletePost(string id);
|
||||
void RestorePost(string id);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
|
||||
namespace SmallSoftwareContracts.BusinessLogicsContracts;
|
||||
|
||||
internal interface IReportContract
|
||||
{
|
||||
Task<List<HistoryOfSoftwareDataModel>> GetDataSoftwaresByHistoryAsync(CancellationToken ct);
|
||||
Task<List<RequestDataModel>> GetDataRequestByPeriodAsync(DateTime dateStart, DateTime dateFinish, CancellationToken ct);
|
||||
Task<Stream> CreateDocumentSoftwaresByHistoryAsync(CancellationToken ct);
|
||||
Task<Stream> CreateDocumentRequestsByPeriodAsync(DateTime dateStart, DateTime dateFinish, CancellationToken ct);
|
||||
Task<List<WorkerSalaryByPeriodDataModel>> GetDataSalaryByPeriodAsync(DateTime dateStart, DateTime dateFinish, CancellationToken ct);
|
||||
Task<Stream> CreateDocumentSalaryByPeriodAsync(DateTime dateStart, DateTime dateFinish, CancellationToken ct);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareContracts.BusinessLogicsContracts;
|
||||
|
||||
internal interface IRequestBusinessLogicContract
|
||||
{
|
||||
|
||||
List<RequestDataModel> GetAllRequestsByPeriod(DateTime fromDate, DateTime toDate);
|
||||
List<RequestDataModel> GetAllRequestsByWorkerByPeriod(string workerId, DateTime fromDate, DateTime toDate);
|
||||
List<RequestDataModel> GetAllRequestsBySoftwareByPeriod(string softwareId, DateTime fromDate, DateTime toDate);
|
||||
RequestDataModel GetRequestByData(string data);
|
||||
void InsertRequest(RequestDataModel requestDataModel);
|
||||
void CancelRequest(string id);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
|
||||
namespace SmallSoftwareContracts.BusinessLogicsContracts;
|
||||
|
||||
internal interface ISalaryBusinessLogicContract
|
||||
{
|
||||
List<SalaryDataModel> GetAllSalariesByPeriod(DateTime fromDate, DateTime toDate);
|
||||
List<SalaryDataModel> GetAllSalariesByPeriodByWorker(DateTime fromDate, DateTime toDate, string workerId);
|
||||
void CalculateSalaryByMonth(DateTime date);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
|
||||
namespace SmallSoftwareContracts.BusinessLogicsContracts;
|
||||
|
||||
internal interface ISoftwareBusinessLogicContract
|
||||
{
|
||||
List<SoftwareDataModel> GetAllSoftwares(bool onlyActive = true);
|
||||
List<SoftwareDataModel> GetAllSoftwaresByManufacturer(string manufacturerId,
|
||||
bool onlyActive = true);
|
||||
List<SoftwareHistoryDataModel> GetSoftwareHistoryBySoftware(string softwareId);
|
||||
SoftwareDataModel GetSoftwareByData(string data);
|
||||
void InsertSoftware(SoftwareDataModel softwareDataModel);
|
||||
void UpdateSoftware(SoftwareDataModel softwareDataModel);
|
||||
void DeleteSoftware(string id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
|
||||
namespace SmallSoftwareContracts.BusinessLogicsContracts;
|
||||
|
||||
internal interface IWorkerBusinessLogicContract
|
||||
{
|
||||
List<WorkerDataModel> GetAllWorkers(bool onlyActive = true);
|
||||
List<WorkerDataModel> GetAllWorkersByPost(string postId, bool onlyActive = true);
|
||||
List<WorkerDataModel> GetAllWorkersByBirthDate(DateTime fromDate, DateTime toDate, bool onlyActive = true);
|
||||
List<WorkerDataModel> GetAllWorkersByEmploymentDate(DateTime fromDate,
|
||||
DateTime toDate, bool onlyActive = true);
|
||||
WorkerDataModel GetWorkerByData(string data);
|
||||
void InsertWorker(WorkerDataModel workerDataModel);
|
||||
void UpdateWorker(WorkerDataModel workerDataModel);
|
||||
void DeleteWorker(string id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace SmallSoftwareContracts.DataModels;
|
||||
|
||||
public class HistoryOfSoftwareDataModel
|
||||
{
|
||||
public required string SoftwareName { get; set; }
|
||||
public required List<string> Histories { get; set; }
|
||||
public required List<string> Data { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using SmallSoftwareContracts.Exceptions;
|
||||
using SmallSoftwareContracts.Extensions;
|
||||
using SmallSoftwareContracts.Infrastructure;
|
||||
using SmallSoftwareContracts.Resources;
|
||||
|
||||
namespace SmallSoftwareContracts.DataModels;
|
||||
|
||||
internal class InstallationRequestDataModel(string softwareId, string requestId, int count, double price) : IValidation
|
||||
{
|
||||
private readonly SoftwareDataModel? _software;
|
||||
|
||||
public string SoftwareId { get; private set; } = softwareId;
|
||||
public string RequestId { get; private set; } = requestId;
|
||||
public int Count { get; private set; } = count;
|
||||
public double Price { get; private set; } = price;
|
||||
|
||||
public string SoftwareName => _software?.SoftwareName ?? string.Empty;
|
||||
public InstallationRequestDataModel(string saleId, string softwareId, int count, double price, SoftwareDataModel software) : this(saleId, softwareId, count, price)
|
||||
{
|
||||
_software = software;
|
||||
}
|
||||
|
||||
public InstallationRequestDataModel() : this(string.Empty, string.Empty, 0, 0) { }
|
||||
|
||||
public void Validate(IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
if (SoftwareId.IsEmpty())
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "SoftwareId"));
|
||||
if (!SoftwareId.IsGuid())
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "SoftwareId"));
|
||||
if (RequestId.IsEmpty())
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "RequestId"));
|
||||
if (!RequestId.IsGuid())
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "RequestId"));
|
||||
if (Count <= 0)
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageLessOrEqualZero"], "Count"));
|
||||
if (Price <= 0)
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageLessOrEqualZero"], "Price"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using SmallSoftwareContracts.Exceptions;
|
||||
using SmallSoftwareContracts.Extensions;
|
||||
using SmallSoftwareContracts.Infrastructure;
|
||||
using SmallSoftwareContracts.Resources;
|
||||
|
||||
namespace SmallSoftwareContracts.DataModels;
|
||||
|
||||
internal class ManufacturerDataModel(string id, string manufacturerName, string?
|
||||
prevManufacturerName, string? prevPrevManufacturerName) : IValidation
|
||||
{
|
||||
public string Id { get; private set; } = id;
|
||||
public string ManufacturerName { get; private set; } = manufacturerName;
|
||||
public string? PrevManufacturerName { get; private set; } =
|
||||
prevManufacturerName;
|
||||
public string? PrevPrevManufacturerName { get; private set; } =
|
||||
prevPrevManufacturerName;
|
||||
|
||||
public ManufacturerDataModel(string id, string manufacturerName) : this(id, manufacturerName, null, null){ }
|
||||
|
||||
public ManufacturerDataModel() : this(string.Empty, string.Empty, null, null) { }
|
||||
|
||||
public void Validate(IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
if (Id.IsEmpty())
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "Id"));
|
||||
|
||||
if (!Id.IsGuid())
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
|
||||
if (ManufacturerName.IsEmpty())
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "ManufacturerName"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using SmallSoftwareContracts.Enums;
|
||||
using SmallSoftwareContracts.Exceptions;
|
||||
using SmallSoftwareContracts.Extensions;
|
||||
using SmallSoftwareContracts.Infrastructure;
|
||||
using SmallSoftwareContracts.Mapper;
|
||||
using SmallSoftwareContracts.Resources;
|
||||
|
||||
namespace SmallSoftwareContracts.DataModels;
|
||||
|
||||
internal class PostDataModel(string postId, string postName, PostType
|
||||
postType, double salary) : IValidation
|
||||
{
|
||||
[AlternativeName("PostId")]
|
||||
public string Id { get; private set; } = postId;
|
||||
public string PostName { get; private set; } = postName;
|
||||
public PostType PostType { get; private set; } = postType;
|
||||
public double Salary { get; private set; } = salary;
|
||||
public PostDataModel() : this(string.Empty, string.Empty, PostType.None, 0) { }
|
||||
public void Validate(IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
if (Id.IsEmpty())
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "Id"));
|
||||
|
||||
if (!Id.IsGuid())
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
|
||||
if (PostName.IsEmpty())
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "PostName"));
|
||||
|
||||
if (PostType == PostType.None)
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "PostType"));
|
||||
|
||||
if (Salary <= 0)
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageLessOrEqualZero"], "Salary"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using SmallSoftwareContracts.Exceptions;
|
||||
using SmallSoftwareContracts.Extensions;
|
||||
using SmallSoftwareContracts.Infrastructure;
|
||||
using SmallSoftwareContracts.Mapper;
|
||||
using SmallSoftwareContracts.Resources;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml;
|
||||
|
||||
|
||||
namespace SmallSoftwareContracts.DataModels;
|
||||
|
||||
|
||||
internal class RequestDataModel : IValidation
|
||||
{
|
||||
private readonly WorkerDataModel? _worker;
|
||||
public string Id { get; private set; }
|
||||
public string WorkerId { get; private set; }
|
||||
public DateTime RequestDate { get; private set; } = DateTime.UtcNow;
|
||||
public string Email { get; private set; }
|
||||
public double Sum { get; private set; }
|
||||
public bool IsCancel { get; private set; }
|
||||
|
||||
[AlternativeName("InstallationRequests")]
|
||||
public List<InstallationRequestDataModel>? Softwares { get; private set; }
|
||||
public string WorkerFIO => _worker?.FIO ?? string.Empty;
|
||||
|
||||
public RequestDataModel() : this(string.Empty, string.Empty, string.Empty, false,new List<InstallationRequestDataModel>(), DateTime.UtcNow) { }
|
||||
|
||||
public RequestDataModel(string id, string workerId, string email, bool isCancel, List<InstallationRequestDataModel> installationRequests, DateTime requestDate)
|
||||
{
|
||||
Id = id;
|
||||
WorkerId = workerId;
|
||||
Email = email;
|
||||
IsCancel = isCancel;
|
||||
Softwares = installationRequests;
|
||||
Sum = Softwares?.Sum(x => x.Price * x.Count) ?? 0;
|
||||
}
|
||||
|
||||
public RequestDataModel(string id, string workerId, string email, double sum, bool isCancel,
|
||||
List<InstallationRequestDataModel> installationRequests, WorkerDataModel worker, DateTime requestDate)
|
||||
: this(id, workerId, email, isCancel, installationRequests, requestDate)
|
||||
{
|
||||
Sum = sum;
|
||||
_worker = worker;
|
||||
}
|
||||
|
||||
public void Validate(IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
if (Id.IsEmpty())
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "Id"));
|
||||
|
||||
if (!Id.IsGuid())
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
|
||||
if (WorkerId.IsEmpty())
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "WorkerId"));
|
||||
|
||||
if (!WorkerId.IsGuid())
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "WorkerId"));
|
||||
|
||||
if (Sum <= 0)
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageLessOrEqualZero"], "Sum"));
|
||||
|
||||
if ((Softwares?.Count ?? 0) == 0)
|
||||
throw new ValidationException(localizer["ValidationExceptionMessageNoProductsInSale"]);
|
||||
|
||||
if (!Regex.IsMatch(Email, @"^[^@\s]+@[^@\s]+\.[^@\s]+$"))
|
||||
throw new ValidationException(localizer["ValidationExceptionMessageIncorrectEmail"]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using SmallSoftwareContracts.Exceptions;
|
||||
using SmallSoftwareContracts.Extensions;
|
||||
using SmallSoftwareContracts.Infrastructure;
|
||||
using SmallSoftwareContracts.Resources;
|
||||
|
||||
namespace SmallSoftwareContracts.DataModels;
|
||||
|
||||
internal class SalaryDataModel(string workerId, DateTime salaryDate, double
|
||||
workerSalary) : IValidation
|
||||
{
|
||||
private readonly WorkerDataModel? _worker;
|
||||
public string WorkerId { get; private set; } = workerId;
|
||||
public DateTime SalaryDate { get; private set; } = salaryDate.ToUniversalTime();
|
||||
public double Salary { get; private set; } = workerSalary;
|
||||
public string WorkerFIO => _worker?.FIO ?? string.Empty;
|
||||
|
||||
public SalaryDataModel(string workerId, DateTime salaryDate, double workerSalary, WorkerDataModel worker) : this(workerId, salaryDate, workerSalary)
|
||||
{
|
||||
_worker = worker;
|
||||
}
|
||||
public SalaryDataModel() : this(string.Empty, DateTime.Now, 0) { }
|
||||
public void Validate(IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
if (WorkerId.IsEmpty())
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "WorkerId"));
|
||||
|
||||
if (!WorkerId.IsGuid())
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "WorkerId"));
|
||||
|
||||
if (Salary <= 0)
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageLessOrEqualZero"], "Salary"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using SmallSoftwareContracts.Enums;
|
||||
using SmallSoftwareContracts.Exceptions;
|
||||
using SmallSoftwareContracts.Extensions;
|
||||
using SmallSoftwareContracts.Infrastructure;
|
||||
using SmallSoftwareContracts.Resources;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
|
||||
namespace SmallSoftwareContracts.DataModels;
|
||||
|
||||
internal class SoftwareDataModel(string id, string softwareName, SoftwareType softwareType, string manufacturerId, double price, bool isDeleted) : IValidation
|
||||
{
|
||||
private readonly ManufacturerDataModel? _manufacturer;
|
||||
public string Id { get; private set; } = id;
|
||||
public string SoftwareName { get; private set; } = softwareName;
|
||||
public SoftwareType SoftwareType { get; private set; } = softwareType;
|
||||
public string ManufacturerId { get; private set; } = manufacturerId;
|
||||
public double Price { get; private set; } = price;
|
||||
public bool IsDeleted { get; private set; } = isDeleted;
|
||||
public string ManufacturerName => _manufacturer?.ManufacturerName ?? string.Empty;
|
||||
|
||||
public SoftwareDataModel(string id, string softwareName, SoftwareType
|
||||
softwareType, string manufacturerId, double price, bool isDeleted,
|
||||
ManufacturerDataModel manufacturer) : this(id, softwareName, softwareType,
|
||||
manufacturerId, price, isDeleted)
|
||||
{
|
||||
_manufacturer = manufacturer;
|
||||
}
|
||||
public SoftwareDataModel(string id, string softwareName, SoftwareType
|
||||
softwareType, string manufacturerId, double price) : this(id, softwareName,
|
||||
softwareType, manufacturerId, price, false)
|
||||
{ }
|
||||
|
||||
public SoftwareDataModel() : this(string.Empty, string.Empty, SoftwareType.None, string.Empty, 0.0, false) { }
|
||||
public void Validate(IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
if (Id.IsEmpty())
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "Id"));
|
||||
if (!Id.IsGuid())
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
if (SoftwareName.IsEmpty())
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "SoftwareName"));
|
||||
if (SoftwareType == SoftwareType.None)
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "SoftwareType"));
|
||||
if (ManufacturerId.IsEmpty())
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "ManufacturerId"));
|
||||
if (!ManufacturerId.IsGuid())
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "ManufacturerId"));
|
||||
if (Price <= 0)
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageLessOrEqualZero"], "Price"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using SmallSoftwareContracts.Exceptions;
|
||||
using SmallSoftwareContracts.Extensions;
|
||||
using SmallSoftwareContracts.Infrastructure;
|
||||
using SmallSoftwareContracts.Resources;
|
||||
|
||||
namespace SmallSoftwareContracts.DataModels;
|
||||
|
||||
internal class SoftwareHistoryDataModel(string softwareId, double oldPrice) : IValidation
|
||||
{
|
||||
private SoftwareDataModel? Software;
|
||||
public string SoftwareId { get; private set; } = softwareId;
|
||||
public double OldPrice { get; private set; } = oldPrice;
|
||||
public DateTime ChangeDate { get; private set; } = DateTime.UtcNow.ToUniversalTime();
|
||||
|
||||
public string SoftwareName => Software?.SoftwareName ?? string.Empty;
|
||||
public SoftwareHistoryDataModel(string softwareId, double oldPrice, DateTime
|
||||
changeDate, SoftwareDataModel software) : this(softwareId, oldPrice)
|
||||
{
|
||||
ChangeDate = changeDate;
|
||||
Software = software;
|
||||
}
|
||||
|
||||
public SoftwareHistoryDataModel() : this(string.Empty, 0) { }
|
||||
|
||||
public void Validate(IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
if (SoftwareId.IsEmpty())
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "SoftwareId"));
|
||||
if (!SoftwareId.IsGuid())
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "SoftwareId"));
|
||||
if (OldPrice <= 0)
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageLessOrEqualZero"], "OldPrice"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using SmallSoftwareContracts.Exceptions;
|
||||
using SmallSoftwareContracts.Extensions;
|
||||
using SmallSoftwareContracts.Infrastructure;
|
||||
using SmallSoftwareContracts.Infrastructure.PostConfigurations;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using SmallSoftwareContracts.Resources;
|
||||
using SmallSoftwareContracts.Mapper;
|
||||
|
||||
namespace SmallSoftwareContracts.DataModels;
|
||||
|
||||
internal class WorkerDataModel(string id, string fio, string postId, DateTime birthDate, DateTime employmentDate, bool isDeleted, PostConfiguration configuration) : IValidation
|
||||
{
|
||||
[AlternativeName("Post")]
|
||||
public PostDataModel? _post;
|
||||
public string Id { get; private set; } = id;
|
||||
public string FIO { get; private set; } = fio;
|
||||
public string PostId { get; private set; } = postId;
|
||||
public DateTime BirthDate { get; private set; } = birthDate.ToUniversalTime();
|
||||
public DateTime EmploymentDate { get; private set; } = employmentDate.ToUniversalTime();
|
||||
public bool IsDeleted { get; private set; } = isDeleted;
|
||||
public string PostName => _post?.PostName ?? string.Empty;
|
||||
[AlternativeName("ConfigurationJson")]
|
||||
[AlternativeName("Configuration")]
|
||||
[PostProcessing(MappingCallMethodName = "ParseJson")]
|
||||
public PostConfiguration ConfigurationModel { get; private set; } = configuration;
|
||||
|
||||
public WorkerDataModel() : this(string.Empty, string.Empty, string.Empty, DateTime.UtcNow, DateTime.UtcNow, false, (PostConfiguration)null)
|
||||
{ }
|
||||
|
||||
public WorkerDataModel(string id, string fio, string postId, DateTime
|
||||
birthDate, DateTime employmentDate, bool isDeleted, PostDataModel post) :
|
||||
this(id, fio, postId, birthDate, employmentDate, isDeleted, new PostConfiguration { Rate = 10 })
|
||||
{
|
||||
_post = post;
|
||||
}
|
||||
|
||||
public WorkerDataModel(string id, string fio, string postId, DateTime birthDate, DateTime employmentDate)
|
||||
: this(id, fio, postId, birthDate, employmentDate, false, new PostConfiguration { Rate = 10 })
|
||||
{ }
|
||||
|
||||
public void Validate(IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
if (Id.IsEmpty())
|
||||
throw new ValidationException(localizer[Messages.ValidationExceptionMessageEmptyField, nameof(Id)]);
|
||||
|
||||
if (!Id.IsGuid())
|
||||
throw new ValidationException(localizer[Messages.ValidationExceptionMessageNotAId, nameof(Id)]);
|
||||
|
||||
if (FIO.IsEmpty())
|
||||
throw new ValidationException(localizer[Messages.ValidationExceptionMessageEmptyField, nameof(FIO)]);
|
||||
|
||||
if (PostId.IsEmpty())
|
||||
throw new ValidationException(localizer[Messages.ValidationExceptionMessageEmptyField, nameof(PostId)]);
|
||||
|
||||
if (!PostId.IsGuid())
|
||||
throw new ValidationException(localizer[Messages.ValidationExceptionMessageNotAId, nameof(PostId)]);
|
||||
|
||||
if (BirthDate.Date > DateTime.Now.AddYears(-16).Date)
|
||||
throw new ValidationException(localizer[Messages.ValidationExceptionMessageMinorsBirthDate, BirthDate.ToShortDateString()]);
|
||||
|
||||
if (EmploymentDate.Date < BirthDate.Date)
|
||||
throw new ValidationException(localizer[Messages.ValidationExceptionMessageEmploymentDateAndBirthDate, EmploymentDate.ToShortDateString(), BirthDate.ToShortDateString()]);
|
||||
|
||||
if ((EmploymentDate - BirthDate).TotalDays / 365 < 16)
|
||||
throw new ValidationException(localizer[Messages.ValidationExceptionMessageMinorsEmploymentDate, EmploymentDate.ToShortDateString(), BirthDate.ToShortDateString()]);
|
||||
|
||||
if (ConfigurationModel is null)
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotInitialized"], "ConfigurationModel"));
|
||||
|
||||
if (ConfigurationModel!.Rate <= 0)
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageLessOrEqualZero"], "Rate"));
|
||||
}
|
||||
|
||||
private PostConfiguration? ParseJson(string json)
|
||||
{
|
||||
var obj = JToken.Parse(json);
|
||||
if (obj is not null)
|
||||
{
|
||||
return obj.Value<string>("Type") switch
|
||||
{
|
||||
nameof(CashierPostConfiguration) => JsonConvert.DeserializeObject<CashierPostConfiguration>(json)!,
|
||||
nameof(SupervisorPostConfiguration) => JsonConvert.DeserializeObject<SupervisorPostConfiguration>(json)!,
|
||||
_ => JsonConvert.DeserializeObject<PostConfiguration>(json)!,
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using SmallSoftwareContracts.Mapper;
|
||||
|
||||
namespace SmallSoftwareContracts.DataModels;
|
||||
|
||||
public class WorkerSalaryByPeriodDataModel
|
||||
{
|
||||
[AlternativeName("FIO")]
|
||||
public required string WorkerFIO { get; set; }
|
||||
public double TotalSalary { get; set; }
|
||||
public DateTime FromPeriod { get; set; }
|
||||
public DateTime ToPeriod { get; set; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace SmallSoftwareContracts.Enums;
|
||||
|
||||
public enum PostType
|
||||
{
|
||||
None = 0,
|
||||
Supervisor = 1,
|
||||
CashierConsultant = 2,
|
||||
SoftInstaller = 3
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace SmallSoftwareContracts.Enums;
|
||||
|
||||
public enum SoftwareType
|
||||
{
|
||||
None = 0,
|
||||
Windows = 1,
|
||||
Linux = 2,
|
||||
MacOS = 3,
|
||||
AudioDriver = 4,
|
||||
GPUDriver = 5
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using SmallSoftwareContracts.Resources;
|
||||
|
||||
namespace SmallSoftwareContracts.Exceptions;
|
||||
internal class ElementDeletedException(string id, IStringLocalizer<Messages> localizer) :
|
||||
Exception(string.Format(localizer["ElementDeletedExceptionMessage"], id))
|
||||
{ }
|
||||
@@ -0,0 +1,11 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using SmallSoftwareContracts.Resources;
|
||||
|
||||
namespace SmallSoftwareContracts.Exceptions;
|
||||
internal class ElementExistsException(string paramName, string paramValue, IStringLocalizer<Messages> localizer) :
|
||||
Exception(string.Format(localizer["ElementExistsExceptionMessage"], paramValue, paramName))
|
||||
{
|
||||
public string ParamName { get; private set; } = paramName;
|
||||
|
||||
public string ParamValue { get; private set; } = paramValue;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using SmallSoftwareContracts.Resources;
|
||||
|
||||
namespace SmallSoftwareContracts.Exceptions;
|
||||
|
||||
internal class ElementNotFoundException(string value, IStringLocalizer<Messages> localizer) :
|
||||
Exception(string.Format(localizer["ElementNotFoundExceptionMessage"], value))
|
||||
{
|
||||
public string Value { get; private set; } = value;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using SmallSoftwareContracts.Resources;
|
||||
|
||||
namespace SmallSoftwareContracts.Exceptions;
|
||||
|
||||
internal class IncorrectDatesException(DateTime start, DateTime end, IStringLocalizer<Messages> localizer) :
|
||||
Exception(string.Format(localizer["IncorrectDatesExceptionMessage"], start.ToShortDateString(), end.ToShortDateString()))
|
||||
{ }
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
namespace SmallSoftwareContracts.Exceptions;
|
||||
|
||||
public class NullListException : Exception
|
||||
{
|
||||
public NullListException() : base("The returned list is null") { }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using SmallSoftwareContracts.Resources;
|
||||
|
||||
namespace SmallSoftwareContracts.Exceptions;
|
||||
|
||||
internal class StorageException(Exception ex, IStringLocalizer<Messages> localizer) :
|
||||
Exception(string.Format(localizer["StorageExceptionMessage"], ex.Message), ex)
|
||||
{ }
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace SmallSoftwareContracts.Exceptions;
|
||||
|
||||
public class ValidationException(string message) : Exception(message)
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareContracts.Extensions;
|
||||
|
||||
public static class DateTimeExtensions
|
||||
{
|
||||
public static bool IsDateNotOlder(this DateTime date, DateTime olderDate)
|
||||
{
|
||||
return date >= olderDate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareContracts.Extensions;
|
||||
|
||||
public static class StringExtensions
|
||||
{
|
||||
public static bool IsEmpty(this string str)
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(str);
|
||||
}
|
||||
|
||||
public static bool IsGuid(this string str)
|
||||
{
|
||||
return Guid.TryParse(str, out _);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace SmallSoftwareContracts.Infrastructure;
|
||||
|
||||
public interface IConfigurationDatabase
|
||||
{
|
||||
string ConnectionString { get; }
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareContracts.Infrastructure;
|
||||
|
||||
public interface IConfigurationSalary
|
||||
{
|
||||
double ExtraSaleSum { get; }
|
||||
int MaxConcurrentThreads { get; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using SmallSoftwareContracts.Resources;
|
||||
|
||||
namespace SmallSoftwareContracts.Infrastructure;
|
||||
|
||||
internal interface IValidation
|
||||
{
|
||||
void Validate(IStringLocalizer<Messages> localizer);
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Net;
|
||||
|
||||
namespace SmallSoftwareContracts.Infrastructure;
|
||||
|
||||
public class OperationResponse
|
||||
{
|
||||
protected HttpStatusCode StatusCode { get; set; }
|
||||
|
||||
protected object? Result { get; set; }
|
||||
|
||||
protected string? FileName { get; set; }
|
||||
|
||||
public IActionResult GetResponse(HttpRequest request, HttpResponse response)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(request);
|
||||
ArgumentNullException.ThrowIfNull(response);
|
||||
response.StatusCode = (int)StatusCode;
|
||||
if (Result is null)
|
||||
{
|
||||
return new StatusCodeResult((int)StatusCode);
|
||||
}
|
||||
if (Result is Stream stream)
|
||||
{
|
||||
return new FileStreamResult(stream, "application/octetstream")
|
||||
{
|
||||
FileDownloadName = FileName
|
||||
};
|
||||
}
|
||||
return new ObjectResult(Result);
|
||||
}
|
||||
|
||||
protected static TResult OK<TResult, TData>(TData data) where TResult : OperationResponse, new() => new() { StatusCode = HttpStatusCode.OK, Result = data };
|
||||
|
||||
protected static TResult OK<TResult, TData>(TData data, string fileName) where TResult : OperationResponse, new() => new()
|
||||
{
|
||||
StatusCode = HttpStatusCode.OK,
|
||||
Result = data,
|
||||
FileName = fileName
|
||||
};
|
||||
|
||||
protected static TResult NoContent<TResult>() where TResult :
|
||||
OperationResponse, new() => new() { StatusCode = HttpStatusCode.NoContent };
|
||||
protected static TResult BadRequest<TResult>(string? errorMessage = null)
|
||||
where TResult : OperationResponse, new() => new()
|
||||
{
|
||||
StatusCode =
|
||||
HttpStatusCode.BadRequest,
|
||||
Result = errorMessage
|
||||
};
|
||||
protected static TResult NotFound<TResult>(string? errorMessage = null)
|
||||
where TResult : OperationResponse, new() => new()
|
||||
{
|
||||
StatusCode =
|
||||
HttpStatusCode.NotFound,
|
||||
Result = errorMessage
|
||||
};
|
||||
protected static TResult InternalServerError<TResult>(string? errorMessage
|
||||
= null) where TResult : OperationResponse, new() => new()
|
||||
{
|
||||
StatusCode =
|
||||
HttpStatusCode.InternalServerError,
|
||||
Result = errorMessage
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace SmallSoftwareContracts.Infrastructure.PostConfigurations;
|
||||
|
||||
public class CashierPostConfiguration : PostConfiguration
|
||||
{
|
||||
public override string Type => nameof(CashierPostConfiguration);
|
||||
public double SalePercent { get; set; }
|
||||
public double BonusForExtraSales { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Globalization;
|
||||
|
||||
namespace SmallSoftwareContracts.Infrastructure.PostConfigurations;
|
||||
public class PostConfiguration
|
||||
{
|
||||
public virtual string Type => nameof(PostConfiguration);
|
||||
public double Rate { get; set; }
|
||||
public string CultureName { get; set; } = CultureInfo.CurrentCulture.Name;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace SmallSoftwareContracts.Infrastructure.PostConfigurations;
|
||||
|
||||
public class SupervisorPostConfiguration : PostConfiguration
|
||||
{
|
||||
public override string Type => nameof(SupervisorPostConfiguration);
|
||||
public double PersonalCountTrendPremium { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace SmallSoftwareContracts.Mapper;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true)]
|
||||
class AlternativeNameAttribute(string alternativeName) : Attribute
|
||||
{
|
||||
public string AlternativeName { get; set; } = alternativeName;
|
||||
}
|
||||
@@ -0,0 +1,305 @@
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json;
|
||||
using SmallSoftwareContracts.Infrastructure.PostConfigurations;
|
||||
|
||||
namespace SmallSoftwareContracts.Mapper;
|
||||
|
||||
public static class CustomMapper
|
||||
{
|
||||
public static To MapObject<To>(object obj, To newObject)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(obj);
|
||||
ArgumentNullException.ThrowIfNull(newObject);
|
||||
var typeFrom = obj.GetType();
|
||||
var typeTo = newObject.GetType();
|
||||
|
||||
var propertiesFrom = typeFrom.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
|
||||
.Where(x => x.CanRead)
|
||||
.ToArray();
|
||||
|
||||
foreach (var property in typeTo.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
|
||||
.Where(x => x.CanWrite))
|
||||
{
|
||||
if (property.GetCustomAttribute<IgnoreMappingAttribute>() is not null)
|
||||
continue;
|
||||
|
||||
var propertyFrom = TryGetPropertyFrom(property, propertiesFrom);
|
||||
if (propertyFrom is null)
|
||||
{
|
||||
FindAndMapDefaultValue(property, newObject);
|
||||
continue;
|
||||
}
|
||||
|
||||
var fromValue = propertyFrom.GetValue(obj);
|
||||
|
||||
var postProcessingAttribute = property.GetCustomAttribute<PostProcessingAttribute>();
|
||||
if (postProcessingAttribute is not null)
|
||||
{
|
||||
var value = PostProcessing(fromValue, postProcessingAttribute, newObject);
|
||||
if (value is not null)
|
||||
{
|
||||
property.SetValue(newObject, value);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (propertyFrom.PropertyType.IsGenericType &&
|
||||
propertyFrom.PropertyType.GetGenericTypeDefinition() == typeof(List<>) &&
|
||||
fromValue is not null)
|
||||
{
|
||||
var elementType = property.PropertyType.GenericTypeArguments[0];
|
||||
|
||||
if (elementType.IsPrimitive || elementType == typeof(string) || elementType.IsValueType)
|
||||
{
|
||||
var original = (IEnumerable)fromValue;
|
||||
var copy = (IList)Activator.CreateInstance(property.PropertyType)!;
|
||||
foreach (var item in original)
|
||||
copy.Add(item);
|
||||
|
||||
property.SetValue(newObject, copy);
|
||||
continue;
|
||||
}
|
||||
|
||||
fromValue = MapListOfObjects(property, fromValue);
|
||||
}
|
||||
|
||||
if (propertyFrom.PropertyType.IsEnum && property.PropertyType.IsEnum)
|
||||
{
|
||||
if (fromValue != null && property.PropertyType != propertyFrom.PropertyType)
|
||||
{
|
||||
fromValue = System.Enum.ToObject(property.PropertyType, Convert.ChangeType(fromValue, System.Enum.GetUnderlyingType(propertyFrom.PropertyType)));
|
||||
}
|
||||
property.SetValue(newObject, fromValue);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (propertyFrom.PropertyType.IsEnum && property.PropertyType == typeof(string) && fromValue != null)
|
||||
{
|
||||
fromValue = fromValue.ToString();
|
||||
}
|
||||
|
||||
else if (!propertyFrom.PropertyType.IsEnum && property.PropertyType.IsEnum && fromValue is not null)
|
||||
{
|
||||
if (fromValue is string stringValue)
|
||||
fromValue = System.Enum.Parse(property.PropertyType, stringValue);
|
||||
else
|
||||
fromValue = System.Enum.ToObject(property.PropertyType, fromValue);
|
||||
}
|
||||
|
||||
if (fromValue is not null)
|
||||
{
|
||||
if (propertyFrom.PropertyType.IsClass
|
||||
&& property.PropertyType.IsClass
|
||||
&& propertyFrom.PropertyType != typeof(string)
|
||||
&& property.PropertyType != typeof(string)
|
||||
&& !property.PropertyType.IsAssignableFrom(propertyFrom.PropertyType))
|
||||
{
|
||||
try
|
||||
{
|
||||
var nestedInstance = Activator.CreateInstance(property.PropertyType);
|
||||
if (nestedInstance != null)
|
||||
{
|
||||
var nestedMapped = MapObject(fromValue, nestedInstance);
|
||||
property.SetValue(newObject, nestedMapped);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
property.SetValue(newObject, fromValue);
|
||||
}
|
||||
}
|
||||
|
||||
var fieldsTo = typeTo.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
|
||||
var fieldsFrom = typeFrom.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
|
||||
foreach (var field in fieldsTo)
|
||||
{
|
||||
if (field.Name.Contains("k__BackingField"))
|
||||
continue;
|
||||
|
||||
if (field.GetCustomAttribute<IgnoreMappingAttribute>() is not null)
|
||||
continue;
|
||||
|
||||
var sourceField = fieldsFrom.FirstOrDefault(f => f.Name == field.Name);
|
||||
object? fromValue = null;
|
||||
|
||||
if (sourceField is not null)
|
||||
{
|
||||
fromValue = sourceField.GetValue(obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
var propertyName = field.Name.TrimStart('_');
|
||||
var sourceProperty = typeFrom.GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
if (sourceProperty is not null && sourceProperty.CanRead)
|
||||
{
|
||||
fromValue = sourceProperty.GetValue(obj);
|
||||
}
|
||||
}
|
||||
|
||||
if (fromValue is null)
|
||||
continue;
|
||||
|
||||
if (field.FieldType.IsClass && field.FieldType != typeof(string))
|
||||
{
|
||||
try
|
||||
{
|
||||
var nested = Activator.CreateInstance(field.FieldType)!;
|
||||
var mapped = MapObject(fromValue, nested);
|
||||
RemoveReadOnly(field);
|
||||
field.SetValue(newObject, mapped);
|
||||
continue;
|
||||
}
|
||||
catch (MissingMethodException)
|
||||
{
|
||||
Console.WriteLine($"Нет конструктора по умолчанию для {field.FieldType}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Ошибка маппинга для {field.Name}: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
RemoveReadOnly(field);
|
||||
field.SetValue(newObject, fromValue);
|
||||
}
|
||||
|
||||
var classPostProcessing = typeTo.GetCustomAttribute<PostProcessingAttribute>();
|
||||
if (classPostProcessing is not null && classPostProcessing.MappingCallMethodName is not null)
|
||||
{
|
||||
var methodInfo = typeTo.GetMethod(classPostProcessing.MappingCallMethodName, BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
methodInfo?.Invoke(newObject, []);
|
||||
}
|
||||
|
||||
return newObject;
|
||||
}
|
||||
|
||||
private static void RemoveReadOnly(FieldInfo field)
|
||||
{
|
||||
if (!field.IsInitOnly)
|
||||
return;
|
||||
|
||||
var attr = typeof(FieldInfo).GetField("m_fieldAttributes", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
if (attr != null)
|
||||
{
|
||||
var current = (FieldAttributes)attr.GetValue(field)!;
|
||||
attr.SetValue(field, current & ~FieldAttributes.InitOnly);
|
||||
}
|
||||
}
|
||||
|
||||
public static To MapObject<To>(object obj) => MapObject(obj, Activator.CreateInstance<To>()!);
|
||||
public static To? MapObjectWithNull<To>(object? obj) => obj is null ? default : MapObject(obj, Activator.CreateInstance<To>());
|
||||
|
||||
private static PropertyInfo? TryGetPropertyFrom(PropertyInfo propertyTo, PropertyInfo[] propertiesFrom)
|
||||
{
|
||||
var customAttribute = propertyTo.GetCustomAttributes<AlternativeNameAttribute>()?
|
||||
.ToArray()
|
||||
.FirstOrDefault(x => propertiesFrom.Any(y => y.Name == x.AlternativeName));
|
||||
if (customAttribute is not null)
|
||||
{
|
||||
return propertiesFrom.FirstOrDefault(x => x.Name == customAttribute.AlternativeName);
|
||||
}
|
||||
return propertiesFrom.FirstOrDefault(x => x.Name == propertyTo.Name);
|
||||
}
|
||||
|
||||
private static object? PostProcessing<T>(object? value, PostProcessingAttribute postProcessingAttribute, T newObject)
|
||||
{
|
||||
if (value is null || newObject is null) return null;
|
||||
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(postProcessingAttribute.MappingCallMethodName))
|
||||
{
|
||||
var methodInfo = newObject.GetType().GetMethod(
|
||||
postProcessingAttribute.MappingCallMethodName,
|
||||
BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
|
||||
|
||||
if (methodInfo != null)
|
||||
{
|
||||
var parameters = methodInfo.GetParameters();
|
||||
|
||||
if (parameters.Length == 1 && parameters[0].ParameterType == typeof(string))
|
||||
{
|
||||
if (value is string strValue)
|
||||
{
|
||||
return methodInfo.Invoke(newObject, [strValue]);
|
||||
}
|
||||
else if (value is PostConfiguration config)
|
||||
{
|
||||
var jsonValue = JsonConvert.SerializeObject(config);
|
||||
return methodInfo.Invoke(newObject, [jsonValue]);
|
||||
}
|
||||
}
|
||||
else if (parameters.Length == 1 && parameters[0].ParameterType == typeof(PostConfiguration))
|
||||
{
|
||||
return methodInfo.Invoke(newObject, [value]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"PostProcessing error: {ex.Message}");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static object? ToLocalTime(object? obj)
|
||||
{
|
||||
if (obj is DateTime date)
|
||||
return date.ToLocalTime();
|
||||
return obj;
|
||||
}
|
||||
|
||||
private static object? ToUniversalTime(object? obj)
|
||||
{
|
||||
if (obj is DateTime date)
|
||||
return date.ToUniversalTime();
|
||||
return obj;
|
||||
}
|
||||
|
||||
private static void FindAndMapDefaultValue<T>(PropertyInfo property, T newObject)
|
||||
{
|
||||
var defaultValueAttribute = property.GetCustomAttribute<DefaultValueAttribute>();
|
||||
if (defaultValueAttribute is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (defaultValueAttribute.DefaultValue is not null)
|
||||
{
|
||||
property.SetValue(newObject, defaultValueAttribute.DefaultValue);
|
||||
return;
|
||||
}
|
||||
|
||||
var value = defaultValueAttribute.Func switch
|
||||
{
|
||||
DefaultValueFunc.UtcNow => DateTime.UtcNow,
|
||||
_ => (object?)null,
|
||||
};
|
||||
|
||||
if (value is not null)
|
||||
{
|
||||
property.SetValue(newObject, value);
|
||||
}
|
||||
}
|
||||
|
||||
private static object? MapListOfObjects(PropertyInfo propertyTo, object list)
|
||||
{
|
||||
var listResult = Activator.CreateInstance(propertyTo.PropertyType);
|
||||
var genericType = propertyTo.PropertyType.GenericTypeArguments[0];
|
||||
var addMethod = propertyTo.PropertyType.GetMethod("Add", new[] { genericType });
|
||||
|
||||
foreach (var elem in (IEnumerable)list)
|
||||
{
|
||||
var newElem = MapObject(elem, Activator.CreateInstance(genericType)!);
|
||||
if (newElem is not null)
|
||||
{
|
||||
addMethod?.Invoke(listResult, [newElem]);
|
||||
}
|
||||
}
|
||||
|
||||
return listResult;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace SmallSoftwareContracts.Mapper;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class)]
|
||||
class DefaultValueAttribute : Attribute
|
||||
{
|
||||
public object? DefaultValue { get; set; }
|
||||
|
||||
public DefaultValueFunc Func { get; set; } = DefaultValueFunc.None;
|
||||
|
||||
[Obsolete("Use Func instead")]
|
||||
public string? FuncName { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace SmallSoftwareContracts.Mapper;
|
||||
|
||||
public enum DefaultValueFunc
|
||||
{
|
||||
None = 0,
|
||||
UtcNow = 1
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace SmallSoftwareContracts.Mapper;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
class IgnoreMappingAttribute : Attribute
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace SmallSoftwareContracts.Mapper;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Field)]
|
||||
class PostProcessingAttribute : Attribute
|
||||
{
|
||||
public string? MappingCallMethodName { get; set; }
|
||||
|
||||
public PostProcessingType ActionType { get; set; } = PostProcessingType.None;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace SmallSoftwareContracts.Mapper;
|
||||
|
||||
enum PostProcessingType
|
||||
{
|
||||
None = -1,
|
||||
|
||||
ToUniversalTime = 1,
|
||||
|
||||
ToLocalTime = 2
|
||||
}
|
||||
405
SmallSoftwareProject/SmallSoftwareContracts/Resources/Messages.Designer.cs
generated
Normal file
405
SmallSoftwareProject/SmallSoftwareContracts/Resources/Messages.Designer.cs
generated
Normal file
@@ -0,0 +1,405 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace SmallSoftwareContracts.Resources {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
||||
/// </summary>
|
||||
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
|
||||
// с помощью такого средства, как ResGen или Visual Studio.
|
||||
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
|
||||
// с параметром /str или перестройте свой проект VS.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Messages {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Messages() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SmallSoftwareContracts.Resources.Messages", typeof(Messages).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Элемент по данным: {0} был удален.
|
||||
/// </summary>
|
||||
internal static string AdapterMessageElementDeletedException {
|
||||
get {
|
||||
return ResourceManager.GetString("AdapterMessageElementDeletedException", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Не найден элемент по данным: {0}.
|
||||
/// </summary>
|
||||
internal static string AdapterMessageElementNotFoundException {
|
||||
get {
|
||||
return ResourceManager.GetString("AdapterMessageElementNotFoundException", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Данные пусты.
|
||||
/// </summary>
|
||||
internal static string AdapterMessageEmptyDate {
|
||||
get {
|
||||
return ResourceManager.GetString("AdapterMessageEmptyDate", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Неправильные даты: {0}.
|
||||
/// </summary>
|
||||
internal static string AdapterMessageIncorrectDatesException {
|
||||
get {
|
||||
return ResourceManager.GetString("AdapterMessageIncorrectDatesException", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Ошибка при обработке данных: {0}.
|
||||
/// </summary>
|
||||
internal static string AdapterMessageInvalidOperationException {
|
||||
get {
|
||||
return ResourceManager.GetString("AdapterMessageInvalidOperationException", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Ошибка при работе с хранилищем данных: {0}.
|
||||
/// </summary>
|
||||
internal static string AdapterMessageStorageException {
|
||||
get {
|
||||
return ResourceManager.GetString("AdapterMessageStorageException", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Переданы неверные данные: {0}.
|
||||
/// </summary>
|
||||
internal static string AdapterMessageValidationException {
|
||||
get {
|
||||
return ResourceManager.GetString("AdapterMessageValidationException", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Дата.
|
||||
/// </summary>
|
||||
internal static string DocumentDocCaptionData {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentDocCaptionData", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Старая цена.
|
||||
/// </summary>
|
||||
internal static string DocumentDocCaptionOldPrice {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentDocCaptionOldPrice", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Название ПО.
|
||||
/// </summary>
|
||||
internal static string DocumentDocCaptionSoftware {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentDocCaptionSoftware", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на ПО по истории.
|
||||
/// </summary>
|
||||
internal static string DocumentDocHeader {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentDocHeader", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Сформировано на дату {0}.
|
||||
/// </summary>
|
||||
internal static string DocumentDocSubHeader {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentDocSubHeader", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Кол-во.
|
||||
/// </summary>
|
||||
internal static string DocumentExcelCaptionCount {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentExcelCaptionCount", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Дата.
|
||||
/// </summary>
|
||||
internal static string DocumentExcelCaptionDate {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentExcelCaptionDate", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на ПО.
|
||||
/// </summary>
|
||||
internal static string DocumentExcelCaptionSoftware {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentExcelCaptionSoftware", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Сумма.
|
||||
/// </summary>
|
||||
internal static string DocumentExcelCaptionSum {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentExcelCaptionSum", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Всего.
|
||||
/// </summary>
|
||||
internal static string DocumentExcelCaptionTotal {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentExcelCaptionTotal", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Заявки за период.
|
||||
/// </summary>
|
||||
internal static string DocumentExcelHeader {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentExcelHeader", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на c {0} по {1}.
|
||||
/// </summary>
|
||||
internal static string DocumentExcelSubHeader {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentExcelSubHeader", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Начисления.
|
||||
/// </summary>
|
||||
internal static string DocumentPdfDiagramCaption {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentPdfDiagramCaption", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Зарплатная ведомость.
|
||||
/// </summary>
|
||||
internal static string DocumentPdfHeader {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentPdfHeader", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на за период с {0} по {1}.
|
||||
/// </summary>
|
||||
internal static string DocumentPdfSubHeader {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentPdfSubHeader", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Нельзя изменить удаленный элемент (идентификатор: {0}).
|
||||
/// </summary>
|
||||
internal static string ElementDeletedExceptionMessage {
|
||||
get {
|
||||
return ResourceManager.GetString("ElementDeletedExceptionMessage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Уже существует элемент со значением {0} параметра {1}.
|
||||
/// </summary>
|
||||
internal static string ElementExistsExceptionMessage {
|
||||
get {
|
||||
return ResourceManager.GetString("ElementExistsExceptionMessage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Элемент не найден по значению = {0}.
|
||||
/// </summary>
|
||||
internal static string ElementNotFoundExceptionMessage {
|
||||
get {
|
||||
return ResourceManager.GetString("ElementNotFoundExceptionMessage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Дата окончания должна быть позже даты начала. Дата начала: {0}. Дата окончания: {1}.
|
||||
/// </summary>
|
||||
internal static string IncorrectDatesExceptionMessage {
|
||||
get {
|
||||
return ResourceManager.GetString("IncorrectDatesExceptionMessage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Недостаточно данных для обработки: {0}.
|
||||
/// </summary>
|
||||
internal static string NotEnoughDataToProcessExceptionMessage {
|
||||
get {
|
||||
return ResourceManager.GetString("NotEnoughDataToProcessExceptionMessage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Не найдены данные.
|
||||
/// </summary>
|
||||
internal static string NotFoundDataMessage {
|
||||
get {
|
||||
return ResourceManager.GetString("NotFoundDataMessage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Дата трудоустройства не может быть раньше даты рождения ({0}, {1}).
|
||||
/// </summary>
|
||||
internal static string ValidationExceptionMessageEmploymentDateAndBirthDate {
|
||||
get {
|
||||
return ResourceManager.GetString("ValidationExceptionMessageEmploymentDateAndBirthDate", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Значение в поле {0} пусто.
|
||||
/// </summary>
|
||||
internal static string ValidationExceptionMessageEmptyField {
|
||||
get {
|
||||
return ResourceManager.GetString("ValidationExceptionMessageEmptyField", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Значение в поле Email не является Email.
|
||||
/// </summary>
|
||||
internal static string ValidationExceptionMessageIncorrectEmail {
|
||||
get {
|
||||
return ResourceManager.GetString("ValidationExceptionMessageIncorrectEmail", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Значение в поле ФИО не является ФИО.
|
||||
/// </summary>
|
||||
internal static string ValidationExceptionMessageIncorrectFIO {
|
||||
get {
|
||||
return ResourceManager.GetString("ValidationExceptionMessageIncorrectFIO", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Значение в поле {0} меньше или равно 0.
|
||||
/// </summary>
|
||||
internal static string ValidationExceptionMessageLessOrEqualZero {
|
||||
get {
|
||||
return ResourceManager.GetString("ValidationExceptionMessageLessOrEqualZero", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Несовершеннолетние не могут быть приняты на работу (Дата рождения: {0}).
|
||||
/// </summary>
|
||||
internal static string ValidationExceptionMessageMinorsBirthDate {
|
||||
get {
|
||||
return ResourceManager.GetString("ValidationExceptionMessageMinorsBirthDate", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Несовершеннолетние не могут быть приняты на работу (Дата трудоустройства {0}, Дата рождения: {1}).
|
||||
/// </summary>
|
||||
internal static string ValidationExceptionMessageMinorsEmploymentDate {
|
||||
get {
|
||||
return ResourceManager.GetString("ValidationExceptionMessageMinorsEmploymentDate", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на В запросе должно быть хотя бы одно ПО.
|
||||
/// </summary>
|
||||
internal static string ValidationExceptionMessageNoSoftwaresCount {
|
||||
get {
|
||||
return ResourceManager.GetString("ValidationExceptionMessageNoSoftwaresCount", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Значение в поле {0} не является типом уникального идентификатора.
|
||||
/// </summary>
|
||||
internal static string ValidationExceptionMessageNotAId {
|
||||
get {
|
||||
return ResourceManager.GetString("ValidationExceptionMessageNotAId", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Значение в поле {0} не проиницализировано.
|
||||
/// </summary>
|
||||
internal static string ValidationExceptionMessageNotInitialized {
|
||||
get {
|
||||
return ResourceManager.GetString("ValidationExceptionMessageNotInitialized", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="AdapterMessageElementDeletedException" xml:space="preserve">
|
||||
<value>Element mit Daten: {0} </value>
|
||||
</data>
|
||||
<data name="AdapterMessageElementNotFoundException" xml:space="preserve">
|
||||
<value>Element mit Daten: {0} nicht gefunden</value>
|
||||
</data>
|
||||
<data name="AdapterMessageEmptyDate" xml:space="preserve">
|
||||
<value>Daten sind leer</value>
|
||||
</data>
|
||||
<data name="AdapterMessageIncorrectDatesException" xml:space="preserve">
|
||||
<value>Ungültige Datumsangaben: {0}</value>
|
||||
</data>
|
||||
<data name="AdapterMessageInvalidOperationException" xml:space="preserve">
|
||||
<value>Fehler bei der Datenverarbeitung: {0}</value>
|
||||
</data>
|
||||
<data name="AdapterMessageStorageException" xml:space="preserve">
|
||||
<value>Fehler beim Zugriff auf den Datenspeicher: {0}</value>
|
||||
</data>
|
||||
<data name="AdapterMessageValidationException" xml:space="preserve">
|
||||
<value>Falsche Daten wurden übergeben: {0}</value>
|
||||
</data>
|
||||
<data name="DocumentDocCaptionData" xml:space="preserve">
|
||||
<value>Datum</value>
|
||||
</data>
|
||||
<data name="DocumentDocCaptionOldPrice" xml:space="preserve">
|
||||
<value>Alter Preis</value>
|
||||
</data>
|
||||
<data name="DocumentDocCaptionSoftware" xml:space="preserve">
|
||||
<value>Softwarename</value>
|
||||
</data>
|
||||
<data name="DocumentDocHeader" xml:space="preserve">
|
||||
<value>Software nach Geschichte</value>
|
||||
</data>
|
||||
<data name="DocumentDocSubHeader" xml:space="preserve">
|
||||
<value>Erstellt am {0}</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionCount" xml:space="preserve">
|
||||
<value>Anzahl</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionDate" xml:space="preserve">
|
||||
<value>Datum</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionSoftware" xml:space="preserve">
|
||||
<value>Software</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionSum" xml:space="preserve">
|
||||
<value>Summe</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionTotal" xml:space="preserve">
|
||||
<value>Gesamtbetrag</value>
|
||||
</data>
|
||||
<data name="DocumentExcelHeader" xml:space="preserve">
|
||||
<value>Anfragen im Zeitraum</value>
|
||||
</data>
|
||||
<data name="DocumentExcelSubHeader" xml:space="preserve">
|
||||
<value>von {0} bis {1}</value>
|
||||
</data>
|
||||
<data name="DocumentPdfDiagramCaption" xml:space="preserve">
|
||||
<value>Abrechnungen</value>
|
||||
</data>
|
||||
<data name="DocumentPdfHeader" xml:space="preserve">
|
||||
<value>Gehaltsabrechnung</value>
|
||||
</data>
|
||||
<data name="DocumentPdfSubHeader" xml:space="preserve">
|
||||
<value> für den Zeitraum von {0} bis {1}</value>
|
||||
</data>
|
||||
<data name="ElementDeletedExceptionMessage" xml:space="preserve">
|
||||
<value>Ein gelöschtes Element (ID: {0}) kann nicht bearbeitet werden</value>
|
||||
</data>
|
||||
<data name="ElementExistsExceptionMessage" xml:space="preserve">
|
||||
<value>Es existiert bereits ein Element mit Wert {0} für Parameter {1}rfhjefwbe</value>
|
||||
</data>
|
||||
<data name="ElementNotFoundExceptionMessage" xml:space="preserve">
|
||||
<value>Element mit Wert = {0} nicht gefunden</value>
|
||||
</data>
|
||||
<data name="IncorrectDatesExceptionMessage" xml:space="preserve">
|
||||
<value>Das Enddatum muss nach dem Startdatum liegen. Startdatum: {0}. Enddatum: {1}</value>
|
||||
</data>
|
||||
<data name="NotEnoughDataToProcessExceptionMessage" xml:space="preserve">
|
||||
<value>Unzureichende Daten zur Verarbeitung: {0}</value>
|
||||
</data>
|
||||
<data name="NotFoundDataMessage" xml:space="preserve">
|
||||
<value>Keine Daten gefunden</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageEmploymentDateAndBirthDate" xml:space="preserve">
|
||||
<value>Das Einstellungsdatum kann nicht vor dem Geburtsdatum liegen ({0}, {1})</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageEmptyField" xml:space="preserve">
|
||||
<value>Das Feld {0} ist leer</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageIncorrectEmail" xml:space="preserve">
|
||||
<value>Der Wert im Feld Email ist kein vollständiger Email.</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageIncorrectFIO" xml:space="preserve">
|
||||
<value>Der Wert im Feld NAME ist kein vollständiger Name.</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageLessOrEqualZero" xml:space="preserve">
|
||||
<value>Der Wert im Feld {0} ist kleiner oder gleich 0</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageMinorsBirthDate" xml:space="preserve">
|
||||
<value>Minderjährige können nicht eingestellt werden (Geburtsdatum = {0})</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageMinorsEmploymentDate" xml:space="preserve">
|
||||
<value>Minderjährige können nicht eingestellt werden (Einstellungsdatum: {0}, Geburtsdatum: {1})</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageNoSoftwaresCount" xml:space="preserve">
|
||||
<value>Es muss mindestens ein Artikel zum Verkauf stehen</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageNotAId" xml:space="preserve">
|
||||
<value>Der Wert im Feld {0} ist kein eindeutiger Identifikator.</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageNotInitialized" xml:space="preserve">
|
||||
<value>Das Feld {0} ist nicht initialisiert</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,234 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="AdapterMessageElementDeletedException" xml:space="preserve">
|
||||
<value>Element by data: {0} was deleted</value>
|
||||
</data>
|
||||
<data name="AdapterMessageElementNotFoundException" xml:space="preserve">
|
||||
<value>Not found element by data: {0}</value>
|
||||
</data>
|
||||
<data name="AdapterMessageEmptyDate" xml:space="preserve">
|
||||
<value>Data is empty</value>
|
||||
</data>
|
||||
<data name="AdapterMessageIncorrectDatesException" xml:space="preserve">
|
||||
<value>Incorrect dates: {0}</value>
|
||||
</data>
|
||||
<data name="AdapterMessageInvalidOperationException" xml:space="preserve">
|
||||
<value>Error processing data: {0}</value>
|
||||
</data>
|
||||
<data name="AdapterMessageStorageException" xml:space="preserve">
|
||||
<value>Error while working with data storage: {0}</value>
|
||||
</data>
|
||||
<data name="AdapterMessageValidationException" xml:space="preserve">
|
||||
<value>Incorrect data transmitted: {0}</value>
|
||||
</data>
|
||||
<data name="DocumentDocCaptionData" xml:space="preserve">
|
||||
<value>Data</value>
|
||||
</data>
|
||||
<data name="DocumentDocCaptionOldPrice" xml:space="preserve">
|
||||
<value>Old price</value>
|
||||
</data>
|
||||
<data name="DocumentDocCaptionSoftware" xml:space="preserve">
|
||||
<value>Software Name</value>
|
||||
</data>
|
||||
<data name="DocumentDocHeader" xml:space="preserve">
|
||||
<value>Software by History</value>
|
||||
</data>
|
||||
<data name="DocumentDocSubHeader" xml:space="preserve">
|
||||
<value>Generated on date {0}</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionCount" xml:space="preserve">
|
||||
<value>Count</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionDate" xml:space="preserve">
|
||||
<value>Data</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionSoftware" xml:space="preserve">
|
||||
<value>Software</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionSum" xml:space="preserve">
|
||||
<value>Summ</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionTotal" xml:space="preserve">
|
||||
<value>Overall</value>
|
||||
</data>
|
||||
<data name="DocumentExcelHeader" xml:space="preserve">
|
||||
<value>Requests in period</value>
|
||||
</data>
|
||||
<data name="DocumentExcelSubHeader" xml:space="preserve">
|
||||
<value>from {0} to {1}</value>
|
||||
</data>
|
||||
<data name="DocumentPdfDiagramCaption" xml:space="preserve">
|
||||
<value>Arrivals</value>
|
||||
</data>
|
||||
<data name="DocumentPdfHeader" xml:space="preserve">
|
||||
<value>Payroll</value>
|
||||
</data>
|
||||
<data name="DocumentPdfSubHeader" xml:space="preserve">
|
||||
<value>for the period from {0} to {1}</value>
|
||||
</data>
|
||||
<data name="ElementDeletedExceptionMessage" xml:space="preserve">
|
||||
<value>Cannot modify a deleted item (id: {0})</value>
|
||||
</data>
|
||||
<data name="ElementExistsExceptionMessage" xml:space="preserve">
|
||||
<value>There is already an element with value {0} of parameter {1}</value>
|
||||
</data>
|
||||
<data name="ElementNotFoundExceptionMessage" xml:space="preserve">
|
||||
<value>Element not found at value = {0}</value>
|
||||
</data>
|
||||
<data name="IncorrectDatesExceptionMessage" xml:space="preserve">
|
||||
<value>The end date must be later than the start date.. StartDate: {0}. EndDate: {1}</value>
|
||||
</data>
|
||||
<data name="NotEnoughDataToProcessExceptionMessage" xml:space="preserve">
|
||||
<value>Not enough data to process: {0}</value>
|
||||
</data>
|
||||
<data name="NotFoundDataMessage" xml:space="preserve">
|
||||
<value>No data found</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageEmploymentDateAndBirthDate" xml:space="preserve">
|
||||
<value>Date of employment cannot be earlier than date of birth ({0}, {1})</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageEmptyField" xml:space="preserve">
|
||||
<value>The value in field {0} is empty</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageIncorrectEmail" xml:space="preserve">
|
||||
<value>The value in the Email field is not a Email</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageIncorrectFIO" xml:space="preserve">
|
||||
<value>The value in the FULL NAME field is not a full name.</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageLessOrEqualZero" xml:space="preserve">
|
||||
<value>The value in field {0} is less than or equal to 0</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageMinorsBirthDate" xml:space="preserve">
|
||||
<value>Minors cannot be hired (BirthDate = {0})</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageMinorsEmploymentDate" xml:space="preserve">
|
||||
<value>Minors cannot be hired (EmploymentDate: {0}, BirthDate {1})</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageNoSoftwaresCount" xml:space="preserve">
|
||||
<value>There must be at least one item on request</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageNotAId" xml:space="preserve">
|
||||
<value>The value in the {0} field is not a unique identifier type.</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageNotInitialized" xml:space="preserve">
|
||||
<value>The value in field {0} is not initialized</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,234 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="AdapterMessageElementDeletedException" xml:space="preserve">
|
||||
<value>Элемент по данным: {0} был удален</value>
|
||||
</data>
|
||||
<data name="AdapterMessageElementNotFoundException" xml:space="preserve">
|
||||
<value>Не найден элемент по данным: {0}</value>
|
||||
</data>
|
||||
<data name="AdapterMessageEmptyDate" xml:space="preserve">
|
||||
<value>Данные пусты</value>
|
||||
</data>
|
||||
<data name="AdapterMessageIncorrectDatesException" xml:space="preserve">
|
||||
<value>Неправильные даты: {0}</value>
|
||||
</data>
|
||||
<data name="AdapterMessageInvalidOperationException" xml:space="preserve">
|
||||
<value>Ошибка при обработке данных: {0}</value>
|
||||
</data>
|
||||
<data name="AdapterMessageStorageException" xml:space="preserve">
|
||||
<value>Ошибка при работе с хранилищем данных: {0}</value>
|
||||
</data>
|
||||
<data name="AdapterMessageValidationException" xml:space="preserve">
|
||||
<value>Переданы неверные данные: {0}</value>
|
||||
</data>
|
||||
<data name="DocumentDocCaptionData" xml:space="preserve">
|
||||
<value>Дата</value>
|
||||
</data>
|
||||
<data name="DocumentDocCaptionOldPrice" xml:space="preserve">
|
||||
<value>Старая цена</value>
|
||||
</data>
|
||||
<data name="DocumentDocCaptionSoftware" xml:space="preserve">
|
||||
<value>Название ПО</value>
|
||||
</data>
|
||||
<data name="DocumentDocHeader" xml:space="preserve">
|
||||
<value>ПО по истории</value>
|
||||
</data>
|
||||
<data name="DocumentDocSubHeader" xml:space="preserve">
|
||||
<value>Сформировано на дату {0}</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionCount" xml:space="preserve">
|
||||
<value>Кол-во</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionDate" xml:space="preserve">
|
||||
<value>Дата</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionSoftware" xml:space="preserve">
|
||||
<value>ПО</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionSum" xml:space="preserve">
|
||||
<value>Сумма</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionTotal" xml:space="preserve">
|
||||
<value>Всего</value>
|
||||
</data>
|
||||
<data name="DocumentExcelHeader" xml:space="preserve">
|
||||
<value>Заявки за период</value>
|
||||
</data>
|
||||
<data name="DocumentExcelSubHeader" xml:space="preserve">
|
||||
<value>c {0} по {1}</value>
|
||||
</data>
|
||||
<data name="DocumentPdfDiagramCaption" xml:space="preserve">
|
||||
<value>Начисления</value>
|
||||
</data>
|
||||
<data name="DocumentPdfHeader" xml:space="preserve">
|
||||
<value>Зарплатная ведомость</value>
|
||||
</data>
|
||||
<data name="DocumentPdfSubHeader" xml:space="preserve">
|
||||
<value>за период с {0} по {1}</value>
|
||||
</data>
|
||||
<data name="ElementDeletedExceptionMessage" xml:space="preserve">
|
||||
<value>Нельзя изменить удаленный элемент (идентификатор: {0})</value>
|
||||
</data>
|
||||
<data name="ElementExistsExceptionMessage" xml:space="preserve">
|
||||
<value>Уже существует элемент со значением {0} параметра {1}</value>
|
||||
</data>
|
||||
<data name="ElementNotFoundExceptionMessage" xml:space="preserve">
|
||||
<value>Элемент не найден по значению = {0}</value>
|
||||
</data>
|
||||
<data name="IncorrectDatesExceptionMessage" xml:space="preserve">
|
||||
<value>Дата окончания должна быть позже даты начала. Дата начала: {0}. Дата окончания: {1}</value>
|
||||
</data>
|
||||
<data name="NotEnoughDataToProcessExceptionMessage" xml:space="preserve">
|
||||
<value>Недостаточно данных для обработки: {0}</value>
|
||||
</data>
|
||||
<data name="NotFoundDataMessage" xml:space="preserve">
|
||||
<value>Не найдены данные</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageEmploymentDateAndBirthDate" xml:space="preserve">
|
||||
<value>Дата трудоустройства не может быть раньше даты рождения ({0}, {1})</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageEmptyField" xml:space="preserve">
|
||||
<value>Значение в поле {0} пусто</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageIncorrectEmail" xml:space="preserve">
|
||||
<value>Значение в поле Email не является Email</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageIncorrectFIO" xml:space="preserve">
|
||||
<value>Значение в поле ФИО не является ФИО</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageLessOrEqualZero" xml:space="preserve">
|
||||
<value>Значение в поле {0} меньше или равно 0</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageMinorsBirthDate" xml:space="preserve">
|
||||
<value>Несовершеннолетние не могут быть приняты на работу (Дата рождения: {0})</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageMinorsEmploymentDate" xml:space="preserve">
|
||||
<value>Несовершеннолетние не могут быть приняты на работу (Дата трудоустройства {0}, Дата рождения: {1})</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageNoSoftwaresCount" xml:space="preserve">
|
||||
<value>В запросе должно быть хотя бы одно ПО</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageNotAId" xml:space="preserve">
|
||||
<value>Значение в поле {0} не является типом уникального идентификатора</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageNotInitialized" xml:space="preserve">
|
||||
<value>Значение в поле {0} не проиницализировано</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -6,4 +6,31 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.3.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.3.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="9.0.4" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<InternalsVisibleTo Include="SmallSoftwareDatabase" />
|
||||
<InternalsVisibleTo Include="SmallSoftwareTests" />
|
||||
<InternalsVisibleTo Include="SmallSoftwareBusinessLogic" />
|
||||
<InternalsVisibleTo Include="SmallSoftwareWebApi" />
|
||||
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" />
|
||||
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Update="Resources\Messages.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Messages.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Resources\Messages.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Messages.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
|
||||
namespace SmallSoftwareContracts.StoragesContracts;
|
||||
|
||||
internal interface IManufacturerStorageContract
|
||||
{
|
||||
List<ManufacturerDataModel> GetList();
|
||||
ManufacturerDataModel? GetElementById(string id);
|
||||
ManufacturerDataModel? GetElementByName(string name);
|
||||
ManufacturerDataModel? GetElementByOldName(string name);
|
||||
void AddElement(ManufacturerDataModel manufacturerDataModel);
|
||||
void UpdElement(ManufacturerDataModel manufacturerDataModel);
|
||||
void DelElement(string id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
|
||||
namespace SmallSoftwareContracts.StoragesContracts;
|
||||
|
||||
internal interface IPostStorageContract
|
||||
{
|
||||
List<PostDataModel> GetList();
|
||||
List<PostDataModel> GetPostWithHistory(string postId);
|
||||
PostDataModel? GetElementById(string id);
|
||||
PostDataModel? GetElementByName(string name);
|
||||
void AddElement(PostDataModel postDataModel);
|
||||
void UpdElement(PostDataModel postDataModel);
|
||||
void DelElement(string id);
|
||||
void ResElement(string id);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
|
||||
namespace SmallSoftwareContracts.StoragesContracts;
|
||||
|
||||
internal interface IRequestStorageContract
|
||||
{
|
||||
Task<List<RequestDataModel>> GetListAsync(DateTime startDate, DateTime endDate, CancellationToken ct);
|
||||
|
||||
List<RequestDataModel> GetList(DateTime? startDate = null,
|
||||
DateTime? endDate = null, string? workerId = null, string? softwareId = null);
|
||||
RequestDataModel? GetElementById(string id);
|
||||
void AddElement(RequestDataModel requestDataModel);
|
||||
void DelElement(string id);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
|
||||
namespace SmallSoftwareContracts.StoragesContracts;
|
||||
|
||||
internal interface ISalaryStorageContract
|
||||
{
|
||||
List<SalaryDataModel> GetList(DateTime startDate, DateTime endDate, string? workerId = null);
|
||||
void AddElement(SalaryDataModel salaryDataModel);
|
||||
Task<List<SalaryDataModel>> GetListAsync(DateTime startDate, DateTime endDate, CancellationToken ct);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareContracts.StoragesContracts;
|
||||
|
||||
internal interface ISoftwareStorageContract
|
||||
{
|
||||
Task<List<SoftwareHistoryDataModel>> GetListAsync(CancellationToken ct);
|
||||
List<SoftwareDataModel> GetList(bool onlyActive = true, string? manufacturerId = null);
|
||||
List<SoftwareHistoryDataModel> GetHistoryBySoftwareId(string softwareId);
|
||||
SoftwareDataModel? GetElementById(string id);
|
||||
SoftwareDataModel? GetElementByName(string name);
|
||||
void AddElement(SoftwareDataModel softwareDataModel);
|
||||
void UpdElement(SoftwareDataModel softwareDataModel);
|
||||
void DelElement(string id);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareContracts.StoragesContracts;
|
||||
|
||||
internal interface IWorkerStorageContract
|
||||
{
|
||||
List<WorkerDataModel> GetList(bool onlyActive = true, string? postId =
|
||||
null, DateTime? fromBirthDate = null, DateTime? toBirthDate = null, DateTime?
|
||||
fromEmploymentDate = null, DateTime? toEmploymentDate = null);
|
||||
WorkerDataModel? GetElementById(string id);
|
||||
WorkerDataModel? GetElementByFIO(string fio);
|
||||
void AddElement(WorkerDataModel workerDataModel);
|
||||
void UpdElement(WorkerDataModel workerDataModel);
|
||||
void DelElement(string id);
|
||||
int GetWorkerTrend(DateTime fromPeriod, DateTime toPeriod);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace SmallSoftwareContracts.ViewModels;
|
||||
|
||||
public class HistoryOfSoftwareViewModel
|
||||
{
|
||||
public required string SoftwareName { get; set; }
|
||||
public required List<string> Histories { get; set; }
|
||||
public required List<string> Data { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareContracts.ViewModels;
|
||||
|
||||
public class InstallationRequestViewModel
|
||||
{
|
||||
public required string SoftwareId { get; set; }
|
||||
public required string SoftwareName { get; set; }
|
||||
public int Count { get; set; }
|
||||
public double Price { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareContracts.ViewModels;
|
||||
|
||||
public class ManufacturerViewModel
|
||||
{
|
||||
public required string Id { get; set; }
|
||||
public required string ManufacturerName { get; set; }
|
||||
public string? PrevManufacturerName { get; set; }
|
||||
public string? PrevPrevManufacturerName { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
using SmallSoftwareContracts.Mapper;
|
||||
|
||||
namespace SmallSoftwareContracts.ViewModels;
|
||||
|
||||
public class PostViewModel
|
||||
{
|
||||
|
||||
[AlternativeName("PostId")]
|
||||
public required string Id { get; set; }
|
||||
public required string PostName { get; set; }
|
||||
public required string PostType { get; set; }
|
||||
public double Salary { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
using SmallSoftwareContracts.Mapper;
|
||||
|
||||
namespace SmallSoftwareContracts.ViewModels;
|
||||
|
||||
public class RequestViewModel
|
||||
{
|
||||
public required string Id { get; set; }
|
||||
public required string WorkerId { get; set; }
|
||||
public required string WorkerFIO { get; set; }
|
||||
|
||||
[PostProcessing(ActionType = PostProcessingType.ToLocalTime)]
|
||||
public DateTime RequestDate { get; set; }
|
||||
public double Sum { get; set; }
|
||||
public bool IsCancel { get; set; }
|
||||
public required List<InstallationRequestViewModel> Softwares { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareContracts.ViewModels;
|
||||
|
||||
public class SalaryViewModel
|
||||
{
|
||||
public required string WorkerId { get; set; }
|
||||
public required string WorkerFIO { get; set; }
|
||||
public DateTime SalaryDate { get; set; }
|
||||
public double Salary { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using SmallSoftwareContracts.Mapper;
|
||||
|
||||
namespace SmallSoftwareContracts.ViewModels;
|
||||
|
||||
public class SoftwareHistoryViewModel
|
||||
{
|
||||
|
||||
[AlternativeName("SoftwareName")]
|
||||
public required string SoftwareName { get; set; }
|
||||
public double OldPrice { get; set; }
|
||||
public DateTime ChangeDate { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace SmallSoftwareContracts.ViewModels;
|
||||
|
||||
public class SoftwareViewModel
|
||||
{
|
||||
public required string Id { get; set; }
|
||||
public required string SoftwareName { get; set; }
|
||||
public required string ManufacturerId { get; set; }
|
||||
public required string ManufacturerName { get; set; }
|
||||
public required string SoftwareType { get; set; }
|
||||
public double Price { get; set; }
|
||||
public bool IsDeleted { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using SmallSoftwareContracts.Mapper;
|
||||
|
||||
namespace SmallSoftwareContracts.ViewModels;
|
||||
|
||||
public class WorkerSalaryByPeriodViewModel
|
||||
{
|
||||
public required string WorkerFIO { get; set; }
|
||||
public double TotalSalary { get; set; }
|
||||
|
||||
[PostProcessing(ActionType = PostProcessingType.ToLocalTime)]
|
||||
public DateTime FromPeriod { get; set; }
|
||||
|
||||
[PostProcessing(ActionType = PostProcessingType.ToLocalTime)]
|
||||
public DateTime ToPeriod { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using SmallSoftwareContracts.Infrastructure.PostConfigurations;
|
||||
using SmallSoftwareContracts.Mapper;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace SmallSoftwareContracts.ViewModels;
|
||||
|
||||
public class WorkerViewModel
|
||||
{
|
||||
|
||||
[AlternativeName("WorkerId")]
|
||||
public required string Id { get; set; }
|
||||
public required string FIO { get; set; }
|
||||
public required string PostId { get; set; }
|
||||
public required string PostName { get; set; }
|
||||
public bool IsDeleted { get; set; }
|
||||
public DateTime BirthDate { get; set; }
|
||||
public DateTime EmploymentDate { get; set; }
|
||||
|
||||
[AlternativeName("ConfigurationModel")]
|
||||
[PostProcessing(MappingCallMethodName = "ParseConfiguration")]
|
||||
public required string Configuration { get; set; }
|
||||
|
||||
public string ParseConfiguration(PostConfiguration model) => JsonSerializer.Serialize(model, new JsonSerializerOptions()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using SmallSoftwareContracts.Infrastructure;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareDatabase;
|
||||
|
||||
class DefaultConfigurationDatabase : IConfigurationDatabase
|
||||
{
|
||||
public string ConnectionString => "";
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Npgsql;
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
using SmallSoftwareContracts.Exceptions;
|
||||
using SmallSoftwareContracts.Mapper;
|
||||
using SmallSoftwareContracts.Resources;
|
||||
using SmallSoftwareContracts.StoragesContracts;
|
||||
using SmallSoftwareDatabase.Models;
|
||||
|
||||
namespace SmallSoftwareDatabase.Implementations;
|
||||
internal class ManufacturerStorageContract(SmallSoftwareDbContext dbContext, IStringLocalizer<Messages> localizer) : IManufacturerStorageContract
|
||||
{
|
||||
private readonly SmallSoftwareDbContext _dbContext = dbContext;
|
||||
private readonly IStringLocalizer<Messages> _localizer = localizer;
|
||||
|
||||
public List<ManufacturerDataModel> GetList()
|
||||
{
|
||||
try
|
||||
{
|
||||
return [.. _dbContext.Manufacturers.Select(x => CustomMapper.MapObject<ManufacturerDataModel>(x))];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
public ManufacturerDataModel? GetElementById(string id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return
|
||||
CustomMapper.MapObjectWithNull<ManufacturerDataModel>(GetManufacturerById(id));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
public ManufacturerDataModel? GetElementByName(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
return
|
||||
CustomMapper.MapObjectWithNull<ManufacturerDataModel>(_dbContext.Manufacturers.FirstOrDefault(x => x.ManufacturerName == name));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
public ManufacturerDataModel? GetElementByOldName(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
return
|
||||
CustomMapper.MapObjectWithNull<ManufacturerDataModel>(_dbContext.Manufacturers.FirstOrDefault(x =>
|
||||
x.PrevManufacturerName == name ||
|
||||
x.PrevPrevManufacturerName == name));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
public void AddElement(ManufacturerDataModel manufacturerDataModel)
|
||||
{
|
||||
try
|
||||
{
|
||||
_dbContext.Manufacturers.Add(CustomMapper.MapObject<Manufacturer>(manufacturerDataModel));
|
||||
_dbContext.SaveChanges();
|
||||
}
|
||||
catch (InvalidOperationException ex) when (ex.TargetSite?.Name ==
|
||||
"ThrowIdentityConflict")
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new ElementExistsException("Id", manufacturerDataModel.Id, _localizer);
|
||||
}
|
||||
catch (DbUpdateException ex) when (ex.InnerException is
|
||||
PostgresException { ConstraintName: "IX_Manufacturers_ManufacturerName" })
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new ElementExistsException("ManufacturerName",
|
||||
manufacturerDataModel.ManufacturerName, _localizer);
|
||||
}
|
||||
catch (DbUpdateException ex) when (ex.InnerException is
|
||||
PostgresException { ConstraintName: "PK_Manufacturers" })
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new ElementExistsException("Id", manufacturerDataModel.Id, _localizer);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
public void UpdElement(ManufacturerDataModel manufacturerDataModel)
|
||||
{
|
||||
try
|
||||
{
|
||||
var element = GetManufacturerById(manufacturerDataModel.Id) ??
|
||||
throw new ElementNotFoundException(manufacturerDataModel.Id, _localizer);
|
||||
if (element.ManufacturerName !=
|
||||
manufacturerDataModel.ManufacturerName)
|
||||
{
|
||||
element.PrevPrevManufacturerName =
|
||||
element.PrevManufacturerName;
|
||||
element.PrevManufacturerName = element.ManufacturerName;
|
||||
element.ManufacturerName =
|
||||
manufacturerDataModel.ManufacturerName;
|
||||
}
|
||||
_dbContext.Manufacturers.Update(element);
|
||||
_dbContext.SaveChanges();
|
||||
}
|
||||
catch (ElementNotFoundException)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw;
|
||||
}
|
||||
catch (DbUpdateException ex) when (ex.InnerException is
|
||||
PostgresException { ConstraintName: "IX_Manufacturers_ManufacturerName" })
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new ElementExistsException("ManufacturerName",
|
||||
manufacturerDataModel.ManufacturerName, _localizer);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
public void DelElement(string id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var element = GetManufacturerById(id) ?? throw new
|
||||
ElementNotFoundException(id, _localizer);
|
||||
_dbContext.Manufacturers.Remove(element);
|
||||
_dbContext.SaveChanges();
|
||||
}
|
||||
catch (ElementNotFoundException)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
private Manufacturer? GetManufacturerById(string id) =>
|
||||
_dbContext.Manufacturers.FirstOrDefault(x => x.Id == id);
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Npgsql;
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
using SmallSoftwareContracts.Exceptions;
|
||||
using SmallSoftwareContracts.Mapper;
|
||||
using SmallSoftwareContracts.Resources;
|
||||
using SmallSoftwareContracts.StoragesContracts;
|
||||
using SmallSoftwareDatabase.Models;
|
||||
|
||||
namespace SmallSoftwareDatabase.Implementations;
|
||||
|
||||
internal class PostStorageContract(SmallSoftwareDbContext dbContext, IStringLocalizer<Messages> localizer) : IPostStorageContract
|
||||
{
|
||||
private readonly SmallSoftwareDbContext _dbContext = dbContext;
|
||||
private readonly IStringLocalizer<Messages> _localizer = localizer;
|
||||
|
||||
public List<PostDataModel> GetList()
|
||||
{
|
||||
try
|
||||
{
|
||||
return [.._dbContext.Posts.Select(x => CustomMapper.MapObject<PostDataModel>(x))];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
public List<PostDataModel> GetPostWithHistory(string postId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return [.. _dbContext.Posts.Where(x => x.PostId == postId).Select(x => CustomMapper.MapObject<PostDataModel>(x))];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
public PostDataModel? GetElementById(string id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return
|
||||
CustomMapper.MapObjectWithNull<PostDataModel>(_dbContext.Posts.FirstOrDefault(x => x.PostId == id &&
|
||||
x.IsActual));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
public PostDataModel? GetElementByName(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
return
|
||||
CustomMapper.MapObjectWithNull<PostDataModel>(_dbContext.Posts.FirstOrDefault(x => x.PostName ==
|
||||
name && x.IsActual));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
public void AddElement(PostDataModel postDataModel)
|
||||
{
|
||||
try
|
||||
{
|
||||
_dbContext.Posts.Add(CustomMapper.MapObject<Post>(postDataModel));
|
||||
_dbContext.SaveChanges();
|
||||
}
|
||||
catch (DbUpdateException ex) when (ex.InnerException is
|
||||
PostgresException { ConstraintName: "IX_Posts_PostName_IsActual" })
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new ElementExistsException("PostName",
|
||||
postDataModel.PostName, _localizer);
|
||||
}
|
||||
catch (DbUpdateException ex) when (ex.InnerException is
|
||||
PostgresException { ConstraintName: "IX_Posts_PostId_IsActual" })
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new ElementExistsException("PostId", postDataModel.Id, _localizer);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
public void UpdElement(PostDataModel postDataModel)
|
||||
{
|
||||
try
|
||||
{
|
||||
var transaction = _dbContext.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var element = GetPostById(postDataModel.Id) ?? throw new
|
||||
ElementNotFoundException(postDataModel.Id, _localizer);
|
||||
if (!element.IsActual)
|
||||
{
|
||||
throw new
|
||||
ElementDeletedException(postDataModel.Id, _localizer);
|
||||
}
|
||||
element.IsActual = false;
|
||||
_dbContext.SaveChanges();
|
||||
var newElement = CustomMapper.MapObject<Post>(postDataModel);
|
||||
_dbContext.Posts.Add(newElement);
|
||||
_dbContext.SaveChanges();
|
||||
transaction.Commit();
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
catch (DbUpdateException ex) when (ex.InnerException is
|
||||
PostgresException { ConstraintName: "IX_Posts_PostName_IsActual" })
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new ElementExistsException("PostName",
|
||||
postDataModel.PostName, _localizer);
|
||||
}
|
||||
catch (Exception ex) when (ex is ElementDeletedException || ex is
|
||||
ElementNotFoundException)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
public void DelElement(string id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var element = GetPostById(id) ?? throw new
|
||||
ElementNotFoundException(id, _localizer);
|
||||
if (!element.IsActual)
|
||||
{
|
||||
throw new ElementDeletedException(id, _localizer);
|
||||
}
|
||||
element.IsActual = false;
|
||||
_dbContext.SaveChanges();
|
||||
}
|
||||
catch
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public void ResElement(string id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var element = GetPostById(id) ?? throw new
|
||||
ElementNotFoundException(id, _localizer);
|
||||
element.IsActual = true;
|
||||
_dbContext.SaveChanges();
|
||||
}
|
||||
catch
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
private Post? GetPostById(string id) => _dbContext.Posts.Where(x =>
|
||||
x.PostId == id).OrderByDescending(x => x.ChangeDate).FirstOrDefault();
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user