forked from slavaxom9k/PIBD-23_Fomichev_V.S._MagicCarpet
Compare commits
25 Commits
lab03_Stor
...
lab08_Mapp
| Author | SHA1 | Date | |
|---|---|---|---|
| 59637a3e18 | |||
| 018a222a2c | |||
| 3791fac299 | |||
| 22b9ea1bc2 | |||
| c9e9186093 | |||
| bf2577198b | |||
| 478200b4a4 | |||
| e984b4d66f | |||
| afe18e1631 | |||
| c9793000e3 | |||
| 064a7c88b2 | |||
| 135619e512 | |||
| 400faf460a | |||
| 618bc7f639 | |||
| 7a0fcca7b1 | |||
| 96b01aeedf | |||
| 770bf77797 | |||
| 6658ada87a | |||
| 6a14c33a91 | |||
| a9142a8b38 | |||
| 42c509fa72 | |||
| eb4c1f037b | |||
| ed32c34921 | |||
| 3a9c533507 | |||
| 5097441b78 |
@@ -1,74 +0,0 @@
|
||||
using MagicCarpetContracts.BusinessLogicContracts;
|
||||
using MagicCarpetContracts.DataModels;
|
||||
using MagicCarpetContracts.Enums;
|
||||
using MagicCarpetContracts.Exceptions;
|
||||
using MagicCarpetContracts.Extensions;
|
||||
using MagicCarpetContracts.StoragesContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetBusinessLogic.Implementations;
|
||||
|
||||
public class AgencyBusinessLogicContract(IAgencyStorageContract agencyStorageContract, ILogger logger) : IAgencyBusinessLogicContract
|
||||
{
|
||||
private readonly IAgencyStorageContract _agencyStorageContract = agencyStorageContract;
|
||||
private readonly ILogger _logger = logger;
|
||||
public List<AgencyDataModel> GetAllComponents()
|
||||
{
|
||||
_logger.LogInformation("GetAllComponents");
|
||||
return _agencyStorageContract.GetList() ?? throw new NullListException();
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public AgencyDataModel GetComponentByData(string data)
|
||||
{
|
||||
_logger.LogInformation("Get element by data: {data}", data);
|
||||
if (data.IsEmpty())
|
||||
{
|
||||
throw new ArgumentNullException(nameof(data));
|
||||
}
|
||||
if (!data.IsGuid())
|
||||
{
|
||||
throw new ElementNotFoundException(data);
|
||||
}
|
||||
return _agencyStorageContract.GetElementById(data) ?? throw new ElementNotFoundException(data);
|
||||
|
||||
return new("", TourType.None, 0, []);
|
||||
}
|
||||
|
||||
public void InsertComponent(AgencyDataModel agencyDataModel)
|
||||
{
|
||||
_logger.LogInformation("New data: {json}", JsonSerializer.Serialize(agencyDataModel));
|
||||
ArgumentNullException.ThrowIfNull(agencyDataModel);
|
||||
agencyDataModel.Validate();
|
||||
_agencyStorageContract.AddElement(agencyDataModel);
|
||||
}
|
||||
|
||||
public void UpdateComponent(AgencyDataModel agencyDataModel)
|
||||
{
|
||||
_logger.LogInformation("Update data: {json}", JsonSerializer.Serialize(agencyDataModel));
|
||||
ArgumentNullException.ThrowIfNull(agencyDataModel);
|
||||
agencyDataModel.Validate();
|
||||
_agencyStorageContract.UpdElement(agencyDataModel);
|
||||
}
|
||||
|
||||
public void DeleteComponent(string id)
|
||||
{
|
||||
logger.LogInformation("Delete by id: {id}", id);
|
||||
if (id.IsEmpty())
|
||||
{
|
||||
throw new ArgumentNullException(nameof(id));
|
||||
}
|
||||
if (!id.IsGuid())
|
||||
{
|
||||
throw new ValidationException("Id is not a unique identifier");
|
||||
}
|
||||
_agencyStorageContract.DelElement(id);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,9 @@
|
||||
using MagicCarpetContracts.DataModels;
|
||||
using MagicCarpetContracts.Exceptions;
|
||||
using MagicCarpetContracts.Extensions;
|
||||
using MagicCarpetContracts.Resources;
|
||||
using MagicCarpetContracts.StoragesContracts;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -14,15 +16,16 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetBusinessLogic.Implementations;
|
||||
|
||||
internal class ClientBusinessLogicContract(IClientStorageContract clientStorageContract, ILogger logger) : IClientBusinessLogicContract
|
||||
internal class ClientBusinessLogicContract(IClientStorageContract clientStorageContract, IStringLocalizer<Messages> localizer, ILogger logger) : IClientBusinessLogicContract
|
||||
{
|
||||
private readonly ILogger _logger = logger;
|
||||
private readonly IClientStorageContract _clientStorageContract = clientStorageContract;
|
||||
private readonly IStringLocalizer<Messages> _localizer = localizer;
|
||||
|
||||
public List<ClientDataModel> GetAllClients()
|
||||
{
|
||||
_logger.LogInformation("GetAllClients");
|
||||
return _clientStorageContract.GetList() ?? throw new NullListException();
|
||||
return _clientStorageContract.GetList();
|
||||
}
|
||||
|
||||
public ClientDataModel GetClientByData(string data)
|
||||
@@ -34,20 +37,20 @@ internal class ClientBusinessLogicContract(IClientStorageContract clientStorageC
|
||||
}
|
||||
if (data.IsGuid())
|
||||
{
|
||||
return _clientStorageContract.GetElementById(data) ?? throw new ElementNotFoundException(data);
|
||||
return _clientStorageContract.GetElementById(data) ?? throw new ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
if (Regex.IsMatch(data, @"^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$"))
|
||||
{
|
||||
return _clientStorageContract.GetElementByPhoneNumber(data) ?? throw new ElementNotFoundException(data);
|
||||
return _clientStorageContract.GetElementByPhoneNumber(data) ?? throw new ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
return _clientStorageContract.GetElementByFIO(data) ?? throw new ElementNotFoundException(data);
|
||||
return _clientStorageContract.GetElementByFIO(data) ?? throw new ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
|
||||
public void InsertClient(ClientDataModel clientDataModel)
|
||||
{
|
||||
_logger.LogInformation("New data: {json}", JsonSerializer.Serialize(clientDataModel));
|
||||
ArgumentNullException.ThrowIfNull(clientDataModel);
|
||||
clientDataModel.Validate();
|
||||
clientDataModel.Validate(_localizer);
|
||||
_clientStorageContract.AddElement(clientDataModel);
|
||||
}
|
||||
|
||||
@@ -55,7 +58,7 @@ internal class ClientBusinessLogicContract(IClientStorageContract clientStorageC
|
||||
{
|
||||
_logger.LogInformation("Update data: {json}", JsonSerializer.Serialize(clientDataModel));
|
||||
ArgumentNullException.ThrowIfNull(clientDataModel);
|
||||
clientDataModel.Validate();
|
||||
clientDataModel.Validate(_localizer);
|
||||
_clientStorageContract.UpdElement(clientDataModel);
|
||||
}
|
||||
|
||||
@@ -68,7 +71,7 @@ internal class ClientBusinessLogicContract(IClientStorageContract clientStorageC
|
||||
}
|
||||
if (!id.IsGuid())
|
||||
{
|
||||
throw new ValidationException("Id is not a unique identifier");
|
||||
throw new ValidationException(string.Format(_localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
}
|
||||
_clientStorageContract.DelElement(id);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
using MagicCarpetContracts.DataModels;
|
||||
using MagicCarpetContracts.Exceptions;
|
||||
using MagicCarpetContracts.Extensions;
|
||||
using MagicCarpetContracts.Resources;
|
||||
using MagicCarpetContracts.StoragesContracts;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -14,15 +16,16 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetBusinessLogic.Implementations;
|
||||
|
||||
internal class EmployeeBusinessLogicContract(IEmployeeStorageContract employeeStorageContract, ILogger logger) : IEmployeeBusinessLogicContract
|
||||
internal class EmployeeBusinessLogicContract(IEmployeeStorageContract employeeStorageContract, IStringLocalizer<Messages> localizer, ILogger logger) : IEmployeeBusinessLogicContract
|
||||
{
|
||||
private readonly ILogger _logger = logger;
|
||||
private readonly IEmployeeStorageContract _employeeStorageContract = employeeStorageContract;
|
||||
private readonly IStringLocalizer<Messages> _localizer = localizer;
|
||||
|
||||
public List<EmployeeDataModel> GetAllEmployees(bool onlyActive = true)
|
||||
{
|
||||
_logger.LogInformation("GetAllEmployees params: {onlyActive}", onlyActive);
|
||||
return _employeeStorageContract.GetList(onlyActive) ?? throw new NullListException();
|
||||
return _employeeStorageContract.GetList(onlyActive);
|
||||
}
|
||||
|
||||
public List<EmployeeDataModel> GetAllEmployeesByPost(string postId, bool onlyActive = true)
|
||||
@@ -34,9 +37,9 @@ internal class EmployeeBusinessLogicContract(IEmployeeStorageContract employeeSt
|
||||
}
|
||||
if (!postId.IsGuid())
|
||||
{
|
||||
throw new ValidationException("The value in the field postId is not a unique identifier.");
|
||||
throw new ValidationException(string.Format(_localizer["ValidationExceptionMessageNotAId"], "PostId"));
|
||||
}
|
||||
return _employeeStorageContract.GetList(onlyActive, postId) ?? throw new NullListException();
|
||||
return _employeeStorageContract.GetList(onlyActive, postId);
|
||||
}
|
||||
|
||||
public List<EmployeeDataModel> GetAllEmployeesByBirthDate(DateTime fromDate, DateTime toDate, bool onlyActive = true)
|
||||
@@ -44,9 +47,9 @@ internal class EmployeeBusinessLogicContract(IEmployeeStorageContract employeeSt
|
||||
_logger.LogInformation("GetAllEmployees params: {onlyActive}, {fromDate}, {toDate}", onlyActive, fromDate, toDate);
|
||||
if (fromDate.IsDateNotOlder(toDate))
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate);
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
return _employeeStorageContract.GetList(onlyActive, fromBirthDate: fromDate, toBirthDate: toDate) ?? throw new NullListException();
|
||||
return _employeeStorageContract.GetList(onlyActive, fromBirthDate: fromDate, toBirthDate: toDate);
|
||||
}
|
||||
|
||||
public List<EmployeeDataModel> GetAllEmployeesByEmploymentDate(DateTime fromDate, DateTime toDate, bool onlyActive = true)
|
||||
@@ -54,9 +57,9 @@ internal class EmployeeBusinessLogicContract(IEmployeeStorageContract employeeSt
|
||||
_logger.LogInformation("GetAllEmployees params: {onlyActive}, {fromDate}, {toDate}", onlyActive, fromDate, toDate);
|
||||
if (fromDate.IsDateNotOlder(toDate))
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate);
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
return _employeeStorageContract.GetList(onlyActive, fromEmploymentDate: fromDate, toEmploymentDate: toDate) ?? throw new NullListException();
|
||||
return _employeeStorageContract.GetList(onlyActive, fromEmploymentDate: fromDate, toEmploymentDate: toDate);
|
||||
}
|
||||
|
||||
public EmployeeDataModel GetEmployeeByData(string data)
|
||||
@@ -68,20 +71,20 @@ internal class EmployeeBusinessLogicContract(IEmployeeStorageContract employeeSt
|
||||
}
|
||||
if (data.IsGuid())
|
||||
{
|
||||
return _employeeStorageContract.GetElementById(data) ?? throw new ElementNotFoundException(data);
|
||||
return _employeeStorageContract.GetElementById(data) ?? throw new ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
if (Regex.IsMatch(data, @"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"))
|
||||
{
|
||||
return _employeeStorageContract.GetElementByEmail(data) ?? throw new ElementNotFoundException(data);
|
||||
return _employeeStorageContract.GetElementByEmail(data) ?? throw new ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
return _employeeStorageContract.GetElementByFIO(data) ?? throw new ElementNotFoundException(data);
|
||||
return _employeeStorageContract.GetElementByFIO(data) ?? throw new ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
|
||||
public void InsertEmployee(EmployeeDataModel employeeDataModel)
|
||||
{
|
||||
_logger.LogInformation("New data: {json}", JsonSerializer.Serialize(employeeDataModel));
|
||||
ArgumentNullException.ThrowIfNull(employeeDataModel);
|
||||
employeeDataModel.Validate();
|
||||
employeeDataModel.Validate(_localizer);
|
||||
_employeeStorageContract.AddElement(employeeDataModel);
|
||||
}
|
||||
|
||||
@@ -89,7 +92,7 @@ internal class EmployeeBusinessLogicContract(IEmployeeStorageContract employeeSt
|
||||
{
|
||||
_logger.LogInformation("Update data: {json}", JsonSerializer.Serialize(employeeDataModel));
|
||||
ArgumentNullException.ThrowIfNull(employeeDataModel);
|
||||
employeeDataModel.Validate();
|
||||
employeeDataModel.Validate(_localizer);
|
||||
_employeeStorageContract.UpdElement(employeeDataModel);
|
||||
}
|
||||
|
||||
@@ -102,7 +105,7 @@ internal class EmployeeBusinessLogicContract(IEmployeeStorageContract employeeSt
|
||||
}
|
||||
if (!id.IsGuid())
|
||||
{
|
||||
throw new ValidationException("Id is not a unique identifier");
|
||||
throw new ValidationException(string.Format(_localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
}
|
||||
_employeeStorageContract.DelElement(id);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
using MagicCarpetContracts.DataModels;
|
||||
using MagicCarpetContracts.Exceptions;
|
||||
using MagicCarpetContracts.Extensions;
|
||||
using MagicCarpetContracts.Resources;
|
||||
using MagicCarpetContracts.StoragesContracts;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -12,14 +14,15 @@ using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
namespace MagicCarpetBusinessLogic.Implementations;
|
||||
|
||||
internal class PostBusinessLogicContract(IPostStorageContract postStorageContract, ILogger logger) : IPostBusinessLogicContract
|
||||
internal class PostBusinessLogicContract(IPostStorageContract postStorageContract, IStringLocalizer<Messages> localizer, ILogger logger) : IPostBusinessLogicContract
|
||||
{
|
||||
private readonly ILogger _logger = logger;
|
||||
private readonly IPostStorageContract _postStorageContract = postStorageContract;
|
||||
public List<PostDataModel> GetAllPosts(bool onlyActive = true)
|
||||
private readonly IStringLocalizer<Messages> _localizer = localizer;
|
||||
public List<PostDataModel> GetAllPosts()
|
||||
{
|
||||
_logger.LogInformation("GetAllPosts params: {onlyActive}", onlyActive);
|
||||
return _postStorageContract.GetList(onlyActive) ?? throw new NullListException();
|
||||
_logger.LogInformation("GetAllPosts");
|
||||
return _postStorageContract.GetList();
|
||||
}
|
||||
|
||||
public List<PostDataModel> GetAllDataOfPost(string postId)
|
||||
@@ -31,9 +34,9 @@ internal class PostBusinessLogicContract(IPostStorageContract postStorageContrac
|
||||
}
|
||||
if (!postId.IsGuid())
|
||||
{
|
||||
throw new ValidationException("The value in the field postId is not a unique identifier.");
|
||||
throw new ValidationException(string.Format(_localizer["ValidationExceptionMessageNotAId"], "PostId"));
|
||||
}
|
||||
return _postStorageContract.GetPostWithHistory(postId) ?? throw new NullListException();
|
||||
return _postStorageContract.GetPostWithHistory(postId);
|
||||
}
|
||||
|
||||
public PostDataModel GetPostByData(string data)
|
||||
@@ -45,16 +48,16 @@ internal class PostBusinessLogicContract(IPostStorageContract postStorageContrac
|
||||
}
|
||||
if (data.IsGuid())
|
||||
{
|
||||
return _postStorageContract.GetElementById(data) ?? throw new ElementNotFoundException(data);
|
||||
return _postStorageContract.GetElementById(data) ?? throw new ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
return _postStorageContract.GetElementByName(data) ?? throw new ElementNotFoundException(data);
|
||||
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();
|
||||
postDataModel.Validate(_localizer);
|
||||
_postStorageContract.AddElement(postDataModel);
|
||||
}
|
||||
|
||||
@@ -62,7 +65,7 @@ internal class PostBusinessLogicContract(IPostStorageContract postStorageContrac
|
||||
{
|
||||
_logger.LogInformation("Update data: {json}", JsonSerializer.Serialize(postDataModel));
|
||||
ArgumentNullException.ThrowIfNull(postDataModel);
|
||||
postDataModel.Validate();
|
||||
postDataModel.Validate(_localizer);
|
||||
_postStorageContract.UpdElement(postDataModel);
|
||||
}
|
||||
|
||||
@@ -75,7 +78,7 @@ internal class PostBusinessLogicContract(IPostStorageContract postStorageContrac
|
||||
}
|
||||
if (!id.IsGuid())
|
||||
{
|
||||
throw new ValidationException("Id is not a unique identifier");
|
||||
throw new ValidationException(string.Format(_localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
}
|
||||
_postStorageContract.DelElement(id);
|
||||
}
|
||||
@@ -89,7 +92,7 @@ internal class PostBusinessLogicContract(IPostStorageContract postStorageContrac
|
||||
}
|
||||
if (!id.IsGuid())
|
||||
{
|
||||
throw new ValidationException("Id is not a unique identifier");
|
||||
throw new ValidationException(string.Format(_localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
}
|
||||
_postStorageContract.ResElement(id);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using MagicCarpetBusinessLogic.OfficePackage;
|
||||
using MagicCarpetContracts.BusinessLogicContracts;
|
||||
using MagicCarpetContracts.DataModels;
|
||||
using MagicCarpetContracts.Exceptions;
|
||||
using MagicCarpetContracts.Extensions;
|
||||
using MagicCarpetContracts.Resources;
|
||||
using MagicCarpetContracts.StoragesContracts;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
namespace MagicCarpetBusinessLogic.Implementations;
|
||||
|
||||
internal class ReportContract : IReportContract
|
||||
{
|
||||
private readonly ITourStorageContract _tourStorageContract;
|
||||
private readonly ISalaryStorageContract _salaryStorageContract;
|
||||
private readonly ISaleStorageContract _saleStorageContract;
|
||||
private readonly BaseWordBuilder _baseWordBuilder;
|
||||
private readonly BaseExcelBuilder _baseExcelBuilder;
|
||||
private readonly BasePdfBuilder _basePdfBuilder;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IStringLocalizer<Messages> _localizer;
|
||||
|
||||
internal readonly string[] _documentHeader;
|
||||
internal readonly string[] _tableHeader;
|
||||
|
||||
public ReportContract(ITourStorageContract tourStorageContract, ISalaryStorageContract salaryStorageContract,
|
||||
ISaleStorageContract saleStorageContract, BaseWordBuilder baseWordBuilder, BaseExcelBuilder baseExcelBuilder,
|
||||
BasePdfBuilder basePdfBuilder, ILogger logger, IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
_tourStorageContract = tourStorageContract;
|
||||
_saleStorageContract = saleStorageContract;
|
||||
_salaryStorageContract = salaryStorageContract;
|
||||
_baseWordBuilder = baseWordBuilder;
|
||||
_baseExcelBuilder = baseExcelBuilder;
|
||||
_basePdfBuilder = basePdfBuilder;
|
||||
_logger = logger;
|
||||
_localizer = localizer;
|
||||
|
||||
_documentHeader = [_localizer["DocumentDocCaptionTour"], _localizer["DocumentDocCaptionPreviousNames"], _localizer["DocumentDocCaptionData"]];
|
||||
_tableHeader = [_localizer["DocumentExcelCaptionDate"], _localizer["DocumentExcelCaptionSum"], _localizer["DocumentExcelCaptionDiscount"], _localizer["DocumentExcelCaptionTour"], _localizer["DocumentExcelCaptionCount"]];
|
||||
}
|
||||
|
||||
|
||||
public Task<List<TourAndTourHistoryDataModel>> GetDataToursHistoryAsync(CancellationToken ct)
|
||||
{
|
||||
_logger.LogInformation("Get data PostHistory");
|
||||
return GetToursHistoriesAsync(ct);
|
||||
}
|
||||
|
||||
public async Task<Stream> CreateDocumentToursHistoryAsync(CancellationToken ct)
|
||||
{
|
||||
_logger.LogInformation("Create report TourHistory");
|
||||
var data = await GetToursHistoriesAsync(ct) ?? throw new InvalidOperationException(_localizer["NotFoundDataMessage"]);
|
||||
|
||||
return _baseWordBuilder
|
||||
.AddHeader(_localizer["DocumentDocHeader"])
|
||||
.AddParagraph(string.Format(_localizer["DocumentDocSubHeader"], DateTime.Now))
|
||||
.AddTable(
|
||||
new[] { 3000, 3000, 3000 },
|
||||
new List<string[]> { _documentHeader }
|
||||
.Concat(data.SelectMany(x =>
|
||||
new[] { new[] { x.TourName, "", "" } }
|
||||
.Concat(x.Histories.Zip(x.Data, (price, date) => new[] { "", price, date }))
|
||||
))
|
||||
.ToList())
|
||||
.Build();
|
||||
}
|
||||
|
||||
private async Task<List<TourAndTourHistoryDataModel>> GetToursHistoriesAsync(CancellationToken ct) =>
|
||||
[.. (await _tourStorageContract.GetHistoriesListAsync(ct)).GroupBy(x => x.TourName).Select(x => new TourAndTourHistoryDataModel {
|
||||
TourName = x.Key, Histories = [.. x.Select(y => y.OldPrice.ToString())], Data = [.. x.Select(y => y.ChangeDate.ToString())] })];
|
||||
|
||||
public async Task<Stream> CreateDocumentSalesByPeriodAsync(DateTime dateStart, DateTime dateFinish, CancellationToken ct)
|
||||
{
|
||||
var tableHeader1 = new string[]
|
||||
{
|
||||
_localizer["DocumentExcelHeaderEmployee"],
|
||||
_localizer["DocumentExcelCaptionDate"],
|
||||
_localizer["DocumentExcelCaptionSum"],
|
||||
_localizer["DocumentExcelCaptionDiscount"],
|
||||
_localizer["DocumentExcelCaptionCocktail"],
|
||||
_localizer["DocumentExcelCaptionCount"]
|
||||
};
|
||||
|
||||
_logger.LogInformation("Create report SalesByPeriod from {dateStart} to {dateFinish}", dateStart, dateFinish);
|
||||
var data = await GetDataBySalesAsync(dateStart, dateFinish, ct) ?? throw new InvalidOperationException(_localizer["NotFoundDataMessage"]);
|
||||
|
||||
var tableRows = new List<string[]>
|
||||
{
|
||||
tableHeader1
|
||||
};
|
||||
|
||||
foreach (var sale in data)
|
||||
{
|
||||
tableRows.Add(new string[]
|
||||
{
|
||||
sale.EmployeeFIO ?? "",
|
||||
sale.SaleDate.ToShortDateString(),
|
||||
sale.Sum.ToString("N2"),
|
||||
sale.Discount.ToString("N2"),
|
||||
"", ""
|
||||
});
|
||||
|
||||
foreach (var cocktail in sale.Tours ?? Enumerable.Empty<SaleTourDataModel>())
|
||||
{
|
||||
tableRows.Add(new string[]
|
||||
{
|
||||
"", "", "", "", cocktail.TourName, cocktail.Count.ToString("N2")
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
tableRows.Add(new string[]
|
||||
{
|
||||
_localizer["DocumentExcelCaptionTotal"], "", data.Sum(x => x.Sum).ToString("N2"), data.Sum(x => x.Discount).ToString("N2"), "", ""
|
||||
});
|
||||
|
||||
return _baseExcelBuilder
|
||||
.AddHeader(_localizer["DocumentExcelHeader"], 0, 6)
|
||||
.AddParagraph(string.Format(_localizer["DocumentExcelSubHeader"], dateStart.ToLocalTime().ToShortDateString(), dateFinish.ToLocalTime().ToShortDateString()), 2)
|
||||
.AddTable([15, 15, 10, 10, 25, 10], tableRows)
|
||||
.Build();
|
||||
}
|
||||
|
||||
public async Task<List<SaleDataModel>> GetDataBySalesAsync(DateTime dateStart, DateTime dateFinish, CancellationToken ct)
|
||||
{
|
||||
if (dateStart.IsDateNotOlder(dateFinish))
|
||||
{
|
||||
throw new IncorrectDatesException(dateStart, dateFinish, _localizer);
|
||||
}
|
||||
return [.. (await _saleStorageContract.GetListAsync(dateStart,
|
||||
dateFinish, ct)).OrderBy(x => x.SaleDate)];
|
||||
}
|
||||
public Task<List<SaleDataModel>> GetDataSaleByPeriodAsync(DateTime dateStart, DateTime dateFinish, CancellationToken ct)
|
||||
{
|
||||
_logger.LogInformation("Get data SalesByPeriod from {dateStart} to {dateFinish}", dateStart, dateFinish);
|
||||
return GetDataBySalesAsync(dateStart, dateFinish, ct);
|
||||
}
|
||||
|
||||
public Task<List<EmployeeSalaryByPeriodDataModel>> 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<EmployeeSalaryByPeriodDataModel>> 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.EmployeeId)
|
||||
.Select(x => new EmployeeSalaryByPeriodDataModel {
|
||||
EmployeeFIO = x.First().EmployeeFIO,
|
||||
TotalSalary = x.Sum(y => y.Salary),
|
||||
FromPeriod = x.Min(y => y.SalaryDate),
|
||||
ToPeriod = x.Max(y => y.SalaryDate)
|
||||
})
|
||||
.OrderBy(x => x.EmployeeFIO)];
|
||||
}
|
||||
|
||||
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("Зарплатная ведомость")
|
||||
.AddParagraph($"за период с {dateStart.ToShortDateString()} по {dateFinish.ToShortDateString()}")
|
||||
.AddPieChart("Начисления", [.. data.Select(x => (x.EmployeeFIO, x.TotalSalary))])
|
||||
.Build();
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,11 @@
|
||||
using MagicCarpetContracts.DataModels;
|
||||
using MagicCarpetContracts.Exceptions;
|
||||
using MagicCarpetContracts.Extensions;
|
||||
using MagicCarpetContracts.Infrastructure;
|
||||
using MagicCarpetContracts.Infrastructure.PostConfigurations;
|
||||
using MagicCarpetContracts.Resources;
|
||||
using MagicCarpetContracts.StoragesContracts;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -12,28 +16,31 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetBusinessLogic.Implementations;
|
||||
internal class SalaryBusinessLogicContract(ISalaryStorageContract salaryStorageContract,ISaleStorageContract saleStorageContract,
|
||||
IPostStorageContract postStorageContract, IEmployeeStorageContract employeeStorageContract, ILogger logger) : ISalaryBusinessLogicContract
|
||||
IPostStorageContract postStorageContract, IEmployeeStorageContract employeeStorageContract, IStringLocalizer<Messages> localizer, ILogger logger, IConfigurationSalary сonfiguration) : ISalaryBusinessLogicContract
|
||||
{
|
||||
private readonly ILogger _logger = logger;
|
||||
private readonly ISalaryStorageContract _salaryStorageContract = salaryStorageContract;
|
||||
private readonly ISaleStorageContract _saleStorageContract = saleStorageContract;
|
||||
private readonly IPostStorageContract _postStorageContract = postStorageContract;
|
||||
private readonly IEmployeeStorageContract _employeeStorageContract = employeeStorageContract;
|
||||
private readonly IConfigurationSalary _salaryConfiguration = сonfiguration;
|
||||
private readonly IStringLocalizer<Messages> _localizer = localizer;
|
||||
private readonly Lock _lockObject = new();
|
||||
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);
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
return _salaryStorageContract.GetList(fromDate, toDate) ?? throw new NullListException();
|
||||
return _salaryStorageContract.GetList(fromDate, toDate);
|
||||
}
|
||||
|
||||
public List<SalaryDataModel> GetAllSalariesByPeriodByEmployee(DateTime fromDate, DateTime toDate, string employeeId)
|
||||
{
|
||||
if (fromDate.IsDateNotOlder(toDate))
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate);
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
if (employeeId.IsEmpty())
|
||||
{
|
||||
@@ -41,10 +48,10 @@ internal class SalaryBusinessLogicContract(ISalaryStorageContract salaryStorageC
|
||||
}
|
||||
if (!employeeId.IsGuid())
|
||||
{
|
||||
throw new ValidationException("The value in the field employeeId is not a unique identifier.");
|
||||
throw new ValidationException(string.Format(_localizer["ValidationExceptionMessageNotAId"], "EmployeeId"));
|
||||
}
|
||||
_logger.LogInformation("GetAllSalaries params: {fromDate}, {toDate}, {employeeId}", fromDate, toDate, employeeId);
|
||||
return _salaryStorageContract.GetList(fromDate, toDate, employeeId) ?? throw new NullListException();
|
||||
return _salaryStorageContract.GetList(fromDate, toDate, employeeId);
|
||||
}
|
||||
|
||||
public void CalculateSalaryByMounth(DateTime date)
|
||||
@@ -52,16 +59,69 @@ internal class SalaryBusinessLogicContract(ISalaryStorageContract salaryStorageC
|
||||
_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 employees = _employeeStorageContract.GetList() ?? throw new NullListException();
|
||||
var employees = _employeeStorageContract.GetList();
|
||||
foreach (var employee in employees)
|
||||
{
|
||||
var sales = _saleStorageContract.GetList(startDate, finishDate, employeeId: employee.Id)?.Sum(x => x.Sum) ??
|
||||
throw new NullListException();
|
||||
var post = _postStorageContract.GetElementById(employee.PostId) ??
|
||||
throw new NullListException();
|
||||
var salary = post.Salary + sales * 0.1;
|
||||
var sales = _saleStorageContract.GetList(startDate, finishDate, employeeId: employee.Id);
|
||||
var post = _postStorageContract.GetElementById(employee.PostId);
|
||||
var salary = post.ConfigurationModel switch
|
||||
{
|
||||
null => 0,
|
||||
TravelAgentPostConfiguration cpc => CalculateSalaryForTravelAgent(sales, startDate, finishDate, cpc),
|
||||
ChiefPostConfiguration spc => CalculateSalaryForChief(startDate, finishDate, spc),
|
||||
PostConfiguration pc => pc.Rate,
|
||||
};
|
||||
_logger.LogDebug("The employee {employeeId} was paid a salary of {salary}", employee.Id, salary);
|
||||
_salaryStorageContract.AddElement(new SalaryDataModel(employee.Id, finishDate, salary));
|
||||
}
|
||||
}
|
||||
private double CalculateSalaryForTravelAgent(List<SaleDataModel> sales, DateTime startDate, DateTime finishDate, TravelAgentPostConfiguration config)
|
||||
{
|
||||
var calcPercent = 0.0;
|
||||
var dates = new List<DateTime>();
|
||||
for (var date = startDate; date < finishDate; date = date.AddDays(1))
|
||||
{
|
||||
dates.Add(date);
|
||||
}
|
||||
|
||||
var parallelOptions = new ParallelOptions
|
||||
{
|
||||
MaxDegreeOfParallelism = _salaryConfiguration.MaxConcurrentThreads
|
||||
};
|
||||
|
||||
Parallel.ForEach(dates, parallelOptions, date =>
|
||||
{
|
||||
var salesInDay = sales.Where(x => x.SaleDate.Date == date.Date).ToArray();
|
||||
if (salesInDay.Length > 0)
|
||||
{
|
||||
lock (_lockObject)
|
||||
{
|
||||
calcPercent += (salesInDay.Sum(x => x.Sum) / salesInDay.Length) * config.SalePercent;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
double calcBonusTask = 0;
|
||||
try
|
||||
{
|
||||
calcBonusTask = sales.Where(x => x.Sum > _salaryConfiguration.ExtraSaleSum).Sum(x => x.Sum) * config.BonusForExtraSales;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error in bonus calculation");
|
||||
}
|
||||
return config.Rate + calcPercent + calcBonusTask;
|
||||
}
|
||||
private double CalculateSalaryForChief(DateTime startDate, DateTime finishDate, ChiefPostConfiguration config)
|
||||
{
|
||||
try
|
||||
{
|
||||
return config.Rate + config.PersonalCountTrendPremium * _employeeStorageContract.GetEmployeeTrend(startDate, finishDate);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error in the chief payroll process");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
using MagicCarpetContracts.DataModels;
|
||||
using MagicCarpetContracts.Exceptions;
|
||||
using MagicCarpetContracts.Extensions;
|
||||
using MagicCarpetContracts.Resources;
|
||||
using MagicCarpetContracts.StoragesContracts;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -13,20 +15,20 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetBusinessLogic.Implementations;
|
||||
|
||||
internal class SaleBusinessLogicContract(ISaleStorageContract saleStorageContract, IAgencyStorageContract agencyStorageContract, ILogger logger) : ISaleBusinessLogicContract
|
||||
internal class SaleBusinessLogicContract(ISaleStorageContract saleStorageContract, IStringLocalizer<Messages> localizer, ILogger logger) : ISaleBusinessLogicContract
|
||||
{
|
||||
private readonly ILogger _logger = logger;
|
||||
private readonly ISaleStorageContract _saleStorageContract = saleStorageContract;
|
||||
private readonly IAgencyStorageContract _agencyStorageContract = agencyStorageContract;
|
||||
private readonly IStringLocalizer<Messages> _localizer = localizer;
|
||||
|
||||
public List<SaleDataModel> GetAllSalesByPeriod(DateTime fromDate, DateTime toDate)
|
||||
{
|
||||
_logger.LogInformation("GetAllSales params: {fromDate}, {toDate}", fromDate, toDate);
|
||||
if (fromDate.IsDateNotOlder(toDate))
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate);
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
return _saleStorageContract.GetList(fromDate, toDate) ?? throw new NullListException();
|
||||
return _saleStorageContract.GetList(fromDate, toDate);
|
||||
}
|
||||
|
||||
public List<SaleDataModel> GetAllSalesByEmployeeByPeriod(string employeeId, DateTime fromDate, DateTime toDate)
|
||||
@@ -34,7 +36,7 @@ internal class SaleBusinessLogicContract(ISaleStorageContract saleStorageContrac
|
||||
_logger.LogInformation("GetAllSales params: {employeeId}, {fromDate}, {toDate}", employeeId, fromDate, toDate);
|
||||
if (fromDate.IsDateNotOlder(toDate))
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate);
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
if (employeeId.IsEmpty())
|
||||
{
|
||||
@@ -44,7 +46,7 @@ internal class SaleBusinessLogicContract(ISaleStorageContract saleStorageContrac
|
||||
{
|
||||
throw new ValidationException("The value in the field employeeId is not a unique identifier.");
|
||||
}
|
||||
return _saleStorageContract.GetList(fromDate, toDate, employeeId: employeeId) ?? throw new NullListException();
|
||||
return _saleStorageContract.GetList(fromDate, toDate, employeeId: employeeId);
|
||||
}
|
||||
|
||||
public List<SaleDataModel> GetAllSalesByClientByPeriod(string clientId, DateTime fromDate, DateTime toDate)
|
||||
@@ -52,7 +54,7 @@ internal class SaleBusinessLogicContract(ISaleStorageContract saleStorageContrac
|
||||
_logger.LogInformation("GetAllSales params: {buyerId}, {fromDate}, {toDate}", clientId, fromDate, toDate);
|
||||
if (fromDate.IsDateNotOlder(toDate))
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate);
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
if (clientId.IsEmpty())
|
||||
{
|
||||
@@ -60,9 +62,9 @@ internal class SaleBusinessLogicContract(ISaleStorageContract saleStorageContrac
|
||||
}
|
||||
if (!clientId.IsGuid())
|
||||
{
|
||||
throw new ValidationException("The value in the field clientId is not a unique identifier.");
|
||||
throw new ValidationException(string.Format(_localizer["ValidationExceptionMessageNotAId"], "ClientId"));
|
||||
}
|
||||
return _saleStorageContract.GetList(fromDate, toDate, clientId: clientId) ?? throw new NullListException();
|
||||
return _saleStorageContract.GetList(fromDate, toDate, clientId: clientId);
|
||||
}
|
||||
|
||||
public List<SaleDataModel> GetAllSalesByTourByPeriod(string tourId, DateTime fromDate, DateTime toDate)
|
||||
@@ -70,7 +72,7 @@ internal class SaleBusinessLogicContract(ISaleStorageContract saleStorageContrac
|
||||
_logger.LogInformation("GetAllSales params: {tourId}, {fromDate}, {toDate}", tourId, fromDate, toDate);
|
||||
if (fromDate.IsDateNotOlder(toDate))
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate);
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
if (tourId.IsEmpty())
|
||||
{
|
||||
@@ -78,9 +80,9 @@ internal class SaleBusinessLogicContract(ISaleStorageContract saleStorageContrac
|
||||
}
|
||||
if (!tourId.IsGuid())
|
||||
{
|
||||
throw new ValidationException("The value in the field tourId is not a unique identifier.");
|
||||
throw new ValidationException(string.Format(_localizer["ValidationExceptionMessageNotAId"], "TourId"));
|
||||
}
|
||||
return _saleStorageContract.GetList(fromDate, toDate, tourId: tourId) ?? throw new NullListException();
|
||||
return _saleStorageContract.GetList(fromDate, toDate, tourId: tourId);
|
||||
}
|
||||
|
||||
public SaleDataModel GetSaleByData(string data)
|
||||
@@ -92,20 +94,16 @@ internal class SaleBusinessLogicContract(ISaleStorageContract saleStorageContrac
|
||||
}
|
||||
if (!data.IsGuid())
|
||||
{
|
||||
throw new ValidationException("Id is not a unique identifier");
|
||||
throw new ValidationException(string.Format(_localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
}
|
||||
return _saleStorageContract.GetElementById(data) ?? throw new ElementNotFoundException(data);
|
||||
return _saleStorageContract.GetElementById(data) ?? throw new ElementNotFoundException(data,_localizer);
|
||||
}
|
||||
|
||||
public void InsertSale(SaleDataModel saleDataModel)
|
||||
{
|
||||
_logger.LogInformation("New data: {json}", JsonSerializer.Serialize(saleDataModel));
|
||||
ArgumentNullException.ThrowIfNull(saleDataModel);
|
||||
saleDataModel.Validate();
|
||||
if (!_agencyStorageContract.CheckComponents(saleDataModel))
|
||||
{
|
||||
throw new InsufficientException("Dont have tour in agency");
|
||||
}
|
||||
saleDataModel.Validate(_localizer);
|
||||
_saleStorageContract.AddElement(saleDataModel);
|
||||
}
|
||||
|
||||
@@ -118,7 +116,7 @@ internal class SaleBusinessLogicContract(ISaleStorageContract saleStorageContrac
|
||||
}
|
||||
if (!id.IsGuid())
|
||||
{
|
||||
throw new ValidationException("Id is not a unique identifier");
|
||||
throw new ValidationException(string.Format(_localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
}
|
||||
_saleStorageContract.DelElement(id);
|
||||
}
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
using MagicCarpetContracts.BusinessLogicContracts;
|
||||
using MagicCarpetContracts.DataModels;
|
||||
using MagicCarpetContracts.Enums;
|
||||
using MagicCarpetContracts.Exceptions;
|
||||
using MagicCarpetContracts.Extensions;
|
||||
using MagicCarpetContracts.StoragesContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetBusinessLogic.Implementations;
|
||||
|
||||
public class SuppliesBusinessLogicContract(ISuppliesStorageContract suppliesStorageContract, ILogger logger) : ISuppliesBusinessLogicContract
|
||||
{
|
||||
private readonly ISuppliesStorageContract _suppliesStorageContract = suppliesStorageContract;
|
||||
private readonly ILogger _logger = logger;
|
||||
|
||||
public List<SuppliesDataModel> GetAllComponents()
|
||||
{
|
||||
_logger.LogInformation("GetAllComponents");
|
||||
return _suppliesStorageContract.GetList() ?? throw new NullListException();
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public SuppliesDataModel GetComponentByData(string data)
|
||||
{
|
||||
_logger.LogInformation("Get element by data: {data}", data);
|
||||
if (data.IsEmpty())
|
||||
{
|
||||
throw new ArgumentNullException(nameof(data));
|
||||
}
|
||||
if (!data.IsGuid())
|
||||
{
|
||||
throw new ElementNotFoundException(data);
|
||||
}
|
||||
return _suppliesStorageContract.GetElementById(data) ?? throw new ElementNotFoundException(data);
|
||||
|
||||
return new("", TourType.None, DateTime.UtcNow, 0, []);
|
||||
}
|
||||
|
||||
public void InsertComponent(SuppliesDataModel suppliesDataModel)
|
||||
{
|
||||
_logger.LogInformation("New data: {json}", JsonSerializer.Serialize(suppliesDataModel));
|
||||
ArgumentNullException.ThrowIfNull(suppliesDataModel);
|
||||
suppliesDataModel.Validate();
|
||||
_suppliesStorageContract.AddElement(suppliesDataModel);
|
||||
}
|
||||
|
||||
public void UpdateComponent(SuppliesDataModel suppliesDataModel)
|
||||
{
|
||||
_logger.LogInformation("Update data: {json}", JsonSerializer.Serialize(suppliesDataModel));
|
||||
ArgumentNullException.ThrowIfNull(suppliesDataModel);
|
||||
suppliesDataModel.Validate();
|
||||
_suppliesStorageContract.UpdElement(suppliesDataModel);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,9 @@
|
||||
using MagicCarpetContracts.DataModels;
|
||||
using MagicCarpetContracts.Exceptions;
|
||||
using MagicCarpetContracts.Extensions;
|
||||
using MagicCarpetContracts.Resources;
|
||||
using MagicCarpetContracts.StoragesContracts;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -13,14 +15,15 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetBusinessLogic.Implementations;
|
||||
|
||||
internal class TourBusinessLogicContract(ITourStorageContract tourStorageContract, ILogger logger) : ITourBusinessLogicContract
|
||||
internal class TourBusinessLogicContract(ITourStorageContract tourStorageContract, IStringLocalizer<Messages> localizer, ILogger logger) : ITourBusinessLogicContract
|
||||
{
|
||||
private readonly ILogger _logger = logger;
|
||||
private readonly ITourStorageContract _tourStorageContract = tourStorageContract;
|
||||
private readonly IStringLocalizer<Messages> _localizer = localizer;
|
||||
public List<TourDataModel> GetAllTours()
|
||||
{
|
||||
_logger.LogInformation("GetAllTours");
|
||||
return _tourStorageContract.GetList() ?? throw new NullListException();
|
||||
return _tourStorageContract.GetList();
|
||||
}
|
||||
|
||||
public List<TourHistoryDataModel> GetTourHistoryByTour(string tourId)
|
||||
@@ -32,9 +35,9 @@ internal class TourBusinessLogicContract(ITourStorageContract tourStorageContrac
|
||||
}
|
||||
if (!tourId.IsGuid())
|
||||
{
|
||||
throw new ValidationException("The value in the field tourId is not a unique identifier.");
|
||||
throw new ValidationException(string.Format(_localizer["ValidationExceptionMessageNotAId"], "TourId"));
|
||||
}
|
||||
return _tourStorageContract.GetHistoryByTourId(tourId) ?? throw new NullListException();
|
||||
return _tourStorageContract.GetHistoryByTourId(tourId);
|
||||
}
|
||||
|
||||
public TourDataModel GetTourByData(string data)
|
||||
@@ -46,23 +49,25 @@ internal class TourBusinessLogicContract(ITourStorageContract tourStorageContrac
|
||||
}
|
||||
if (data.IsGuid())
|
||||
{
|
||||
return _tourStorageContract.GetElementById(data) ?? throw new ElementNotFoundException(data);
|
||||
return _tourStorageContract.GetElementById(data) ?? throw new ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
return _tourStorageContract.GetElementByName(data) ?? throw new ElementNotFoundException(data);
|
||||
return _tourStorageContract.GetElementByName(data) ?? throw new ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
|
||||
public void InsertTour(TourDataModel tourDataModel)
|
||||
{
|
||||
_logger.LogInformation("New data: {json}", JsonSerializer.Serialize(tourDataModel));
|
||||
ArgumentNullException.ThrowIfNull(tourDataModel);
|
||||
tourDataModel.Validate();
|
||||
tourDataModel.Validate(_localizer);
|
||||
_tourStorageContract.AddElement(tourDataModel);
|
||||
}
|
||||
|
||||
public void UpdateTour(TourDataModel tourDataModel)
|
||||
{
|
||||
_logger.LogInformation("Update data: {json}", JsonSerializer.Serialize(tourDataModel));
|
||||
ArgumentNullException.ThrowIfNull(tourDataModel);
|
||||
tourDataModel.Validate();
|
||||
tourDataModel.Validate(_localizer);
|
||||
_tourStorageContract.UpdElement(tourDataModel);
|
||||
}
|
||||
|
||||
public void DeleteTour(string id)
|
||||
@@ -74,7 +79,7 @@ internal class TourBusinessLogicContract(ITourStorageContract tourStorageContrac
|
||||
}
|
||||
if (!id.IsGuid())
|
||||
{
|
||||
throw new ValidationException("Id is not a unique identifier");
|
||||
throw new ValidationException(string.Format(_localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
}
|
||||
_tourStorageContract.DelElement(id);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<InternalsVisibleTo Include="MagicCarpetTests" />
|
||||
<InternalsVisibleTo Include="MagicCarpetWebApi" />
|
||||
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.2" />
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="3.3.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.4" />
|
||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetBusinessLogic.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 MagicCarpetBusinessLogic.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,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetBusinessLogic.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,89 @@
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.DocumentObjectModel.Shapes.Charts;
|
||||
using MigraDoc.Rendering;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetBusinessLogic.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 style = _document.Styles.AddStyle("NormalBold", "Normal");
|
||||
style.Font.Bold = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,308 @@
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using DocumentFormat.OpenXml;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetBusinessLogic.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.BoldTextWithoutBorder);
|
||||
for (int i = startIndex + 1; i < startIndex + count; ++i)
|
||||
{
|
||||
CreateCell(i, _rowIndex, "", StyleIndex.SimpleTextWithoutBorder);
|
||||
}
|
||||
|
||||
_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.BoldTextWithBorder);
|
||||
}
|
||||
|
||||
_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.SimpleTextWithBorder);
|
||||
}
|
||||
|
||||
_rowIndex++;
|
||||
}
|
||||
|
||||
for (var j = 0; j < data.Last().Length; ++j)
|
||||
{
|
||||
CreateCell(j, _rowIndex, data.Last()[j], StyleIndex.BoldTextWithBorder);
|
||||
}
|
||||
|
||||
_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);
|
||||
|
||||
// Default Fill
|
||||
var fills = new Fills() { Count = 1 };
|
||||
fills.Append(new Fill
|
||||
{
|
||||
PatternFill = new PatternFill() { PatternType = new EnumValue<PatternValues>(PatternValues.None) }
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(fills);
|
||||
|
||||
// Default Border
|
||||
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 }
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(borders);
|
||||
|
||||
// Default cell format and a date cell format
|
||||
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.Center,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
cellFormats.Append(new CellFormat
|
||||
{
|
||||
NumberFormatId = 0,
|
||||
FormatId = 0,
|
||||
FontId = 1,
|
||||
BorderId = 1,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Horizontal = HorizontalAlignmentValues.Center,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(cellFormats);
|
||||
}
|
||||
|
||||
private enum StyleIndex
|
||||
{
|
||||
SimpleTextWithoutBorder = 0,
|
||||
SimpleTextWithBorder = 1,
|
||||
BoldTextWithoutBorder = 2,
|
||||
BoldTextWithBorder = 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,99 @@
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetBusinessLogic.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());
|
||||
run.AppendChild(new RunProperties(new Bold()));
|
||||
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,22 @@
|
||||
using MagicCarpetContracts.AdapterContracts.OperationResponses;
|
||||
using MagicCarpetContracts.BindingModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.AdapterContracts;
|
||||
|
||||
public interface IClientAdapter
|
||||
{
|
||||
ClientOperationResponse GetList();
|
||||
|
||||
ClientOperationResponse GetElement(string data);
|
||||
|
||||
ClientOperationResponse RegisterClient(ClientBindingModel clientModel);
|
||||
|
||||
ClientOperationResponse ChangeClientInfo(ClientBindingModel clientModel);
|
||||
|
||||
ClientOperationResponse RemoveClient(string id);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using MagicCarpetContracts.AdapterContracts.OperationResponses;
|
||||
using MagicCarpetContracts.BindingModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.AdapterContracts;
|
||||
|
||||
public interface IEmployeeAdapter
|
||||
{
|
||||
EmployeeOperationResponse GetList(bool includeDeleted);
|
||||
|
||||
EmployeeOperationResponse GetPostList(string id, bool includeDeleted);
|
||||
|
||||
EmployeeOperationResponse GetListByBirthDate(DateTime fromDate, DateTime toDate, bool includeDeleted);
|
||||
|
||||
EmployeeOperationResponse GetListByEmploymentDate(DateTime fromDate, DateTime toDate, bool includeDeleted);
|
||||
|
||||
EmployeeOperationResponse GetElement(string data);
|
||||
|
||||
EmployeeOperationResponse RegisterEmployee(EmployeeBindingModel employeeModel);
|
||||
|
||||
EmployeeOperationResponse ChangeEmployeeInfo(EmployeeBindingModel employeeModel);
|
||||
|
||||
EmployeeOperationResponse RemoveEmployee(string id);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using MagicCarpetContracts.AdapterContracts.OperationResponses;
|
||||
using MagicCarpetContracts.BindingModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.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,18 @@
|
||||
using MagicCarpetContracts.AdapterContracts.OperationResponses;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.AdapterContracts;
|
||||
|
||||
public interface IReportAdapter
|
||||
{
|
||||
Task<ReportOperationResponse> GetDataToursHistoryAsync(CancellationToken ct);
|
||||
Task<ReportOperationResponse> GetDataBySalesByPeriodAsync(DateTime dateStart, DateTime dateFinish, CancellationToken ct);
|
||||
Task<ReportOperationResponse> GetDataSalaryByPeriodAsync(DateTime dateStart, DateTime dateFinish, CancellationToken ct);
|
||||
Task<ReportOperationResponse> CreateDocumentToursHistoryAsync(CancellationToken ct);
|
||||
Task<ReportOperationResponse> CreateDocumentSalesByPeriodAsync(DateTime dateStart, DateTime dateFinish, CancellationToken ct);
|
||||
Task<ReportOperationResponse> CreateDocumentSalaryByPeriodAsync(DateTime dateStart, DateTime dateFinish, CancellationToken ct);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using MagicCarpetContracts.AdapterContracts.OperationResponses;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.AdapterContracts;
|
||||
|
||||
public interface ISalaryAdapter
|
||||
{
|
||||
SalaryOperationResponse GetListByPeriod(DateTime fromDate, DateTime toDate);
|
||||
SalaryOperationResponse GetListByPeriodByEmployee(DateTime fromDate, DateTime toDate, string employeeId);
|
||||
SalaryOperationResponse CalculateSalary(DateTime date);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using MagicCarpetContracts.AdapterContracts.OperationResponses;
|
||||
using MagicCarpetContracts.BindingModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.AdapterContracts;
|
||||
|
||||
public interface ISaleAdapter
|
||||
{
|
||||
SaleOperationResponse GetList(DateTime fromDate, DateTime toDate);
|
||||
|
||||
SaleOperationResponse GetEmployeeList(string id, DateTime fromDate, DateTime toDate);
|
||||
|
||||
SaleOperationResponse GetClientList(string id, DateTime fromDate, DateTime toDate);
|
||||
|
||||
SaleOperationResponse GetTourList(string id, DateTime fromDate, DateTime toDate);
|
||||
|
||||
SaleOperationResponse GetElement(string id);
|
||||
|
||||
SaleOperationResponse MakeSale(SaleBindingModel saleModel);
|
||||
|
||||
SaleOperationResponse CancelSale(string id);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using MagicCarpetContracts.AdapterContracts.OperationResponses;
|
||||
using MagicCarpetContracts.BindingModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.AdapterContracts;
|
||||
|
||||
public interface ITourAdapter
|
||||
{
|
||||
TourOperationResponse GetList(bool includeDeleted);
|
||||
|
||||
TourOperationResponse GetHistory(string id);
|
||||
|
||||
TourOperationResponse GetElement(string data);
|
||||
|
||||
TourOperationResponse RegisterTour(TourBindingModel tourModel);
|
||||
|
||||
TourOperationResponse ChangeTourInfo(TourBindingModel tourModel);
|
||||
|
||||
TourOperationResponse RemoveTour(string id);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using MagicCarpetContracts.Infrastructure;
|
||||
using MagicCarpetContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.AdapterContracts.OperationResponses;
|
||||
|
||||
public class ClientOperationResponse : OperationResponse
|
||||
{
|
||||
public static ClientOperationResponse OK(List<ClientViewModel> data) => OK<ClientOperationResponse, List<ClientViewModel>>(data);
|
||||
|
||||
public static ClientOperationResponse OK(ClientViewModel data) => OK<ClientOperationResponse, ClientViewModel>(data);
|
||||
|
||||
public static ClientOperationResponse NoContent() => NoContent<ClientOperationResponse>();
|
||||
|
||||
public static ClientOperationResponse BadRequest(string message) => BadRequest<ClientOperationResponse>(message);
|
||||
|
||||
public static ClientOperationResponse NotFound(string message) => NotFound<ClientOperationResponse>(message);
|
||||
|
||||
public static ClientOperationResponse InternalServerError(string message) => InternalServerError<ClientOperationResponse>(message);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using MagicCarpetContracts.Infrastructure;
|
||||
using MagicCarpetContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.AdapterContracts.OperationResponses;
|
||||
|
||||
public class EmployeeOperationResponse : OperationResponse
|
||||
{
|
||||
public static EmployeeOperationResponse OK(List<EmployeeViewModel> data) => OK<EmployeeOperationResponse, List<EmployeeViewModel>>(data);
|
||||
|
||||
public static EmployeeOperationResponse OK(EmployeeViewModel data) => OK<EmployeeOperationResponse, EmployeeViewModel>(data);
|
||||
|
||||
public static EmployeeOperationResponse NoContent() => NoContent<EmployeeOperationResponse>();
|
||||
|
||||
public static EmployeeOperationResponse NotFound(string message) => NotFound<EmployeeOperationResponse>(message);
|
||||
|
||||
public static EmployeeOperationResponse BadRequest(string message) => BadRequest<EmployeeOperationResponse>(message);
|
||||
|
||||
public static EmployeeOperationResponse InternalServerError(string message) => InternalServerError<EmployeeOperationResponse>(message);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using MagicCarpetContracts.Infrastructure;
|
||||
using MagicCarpetContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.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,24 @@
|
||||
using MagicCarpetContracts.Infrastructure;
|
||||
using MagicCarpetContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.AdapterContracts.OperationResponses;
|
||||
|
||||
public class ReportOperationResponse : OperationResponse
|
||||
{
|
||||
public static ReportOperationResponse OK(List<TourAndTourHistoryViewModel> data) => OK<ReportOperationResponse, List<TourAndTourHistoryViewModel>>(data);
|
||||
|
||||
public static ReportOperationResponse OK(List<SaleViewModel> data) => OK<ReportOperationResponse, List<SaleViewModel>>(data);
|
||||
|
||||
public static ReportOperationResponse OK(List<EmployeeSalaryByPeriodViewModel> data) => OK<ReportOperationResponse, List<EmployeeSalaryByPeriodViewModel>>(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);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using MagicCarpetContracts.Infrastructure;
|
||||
using MagicCarpetContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.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,24 @@
|
||||
using MagicCarpetContracts.Infrastructure;
|
||||
using MagicCarpetContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.AdapterContracts.OperationResponses;
|
||||
|
||||
public class SaleOperationResponse : OperationResponse
|
||||
{
|
||||
public static SaleOperationResponse OK(List<SaleViewModel> data) => OK<SaleOperationResponse, List<SaleViewModel>>(data);
|
||||
|
||||
public static SaleOperationResponse OK(SaleViewModel data) => OK<SaleOperationResponse, SaleViewModel>(data);
|
||||
|
||||
public static SaleOperationResponse NoContent() => NoContent<SaleOperationResponse>();
|
||||
|
||||
public static SaleOperationResponse NotFound(string message) => NotFound<SaleOperationResponse>(message);
|
||||
|
||||
public static SaleOperationResponse BadRequest(string message) => BadRequest<SaleOperationResponse>(message);
|
||||
|
||||
public static SaleOperationResponse InternalServerError(string message) => InternalServerError<SaleOperationResponse>(message);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using MagicCarpetContracts.Infrastructure;
|
||||
using MagicCarpetContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.AdapterContracts.OperationResponses;
|
||||
|
||||
public class TourOperationResponse : OperationResponse
|
||||
{
|
||||
public static TourOperationResponse OK(List<TourViewModel> data) => OK<TourOperationResponse, List<TourViewModel>>(data);
|
||||
|
||||
public static TourOperationResponse OK(List<TourHistoryViewModel> data) => OK<TourOperationResponse, List<TourHistoryViewModel>>(data);
|
||||
|
||||
public static TourOperationResponse OK(TourViewModel data) => OK<TourOperationResponse, TourViewModel>(data);
|
||||
|
||||
public static TourOperationResponse NoContent() => NoContent<TourOperationResponse>();
|
||||
|
||||
public static TourOperationResponse NotFound(string message) => NotFound<TourOperationResponse>(message);
|
||||
|
||||
public static TourOperationResponse BadRequest(string message) => BadRequest<TourOperationResponse>(message);
|
||||
|
||||
public static TourOperationResponse InternalServerError(string message) => InternalServerError<TourOperationResponse>(message);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.BindingModels;
|
||||
|
||||
public class ClientBindingModel
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
|
||||
public string? FIO { get; set; }
|
||||
|
||||
public string? PhoneNumber { get; set; }
|
||||
|
||||
public double DiscountSize { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.BindingModels;
|
||||
|
||||
public class EmployeeBindingModel
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
|
||||
public string? FIO { get; set; }
|
||||
|
||||
public string? Email { get; set; }
|
||||
|
||||
public string? PostId { get; set; }
|
||||
|
||||
public DateTime BirthDate { get; set; }
|
||||
|
||||
public DateTime EmploymentDate { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using MagicCarpetContracts.Infrastructure.PostConfigurations;
|
||||
using MagicCarpetContracts.Mapper;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.BindingModels;
|
||||
|
||||
public class PostBindingModel
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
|
||||
public string? PostId => Id;
|
||||
|
||||
public string? PostName { get; set; }
|
||||
|
||||
public string? PostType { get; set; }
|
||||
|
||||
[PostProcessing(MappingCallMethodName = "ParseConfiguration")]
|
||||
public string? ConfigurationJson { get; set; }
|
||||
|
||||
private string ParseConfiguration(PostConfiguration model) =>
|
||||
System.Text.Json.JsonSerializer.Serialize(model, new JsonSerializerOptions() { PropertyNameCaseInsensitive = true });
|
||||
private PostConfiguration? ParseJson(string json)
|
||||
{
|
||||
if (ConfigurationJson is null)
|
||||
return null;
|
||||
|
||||
var obj = JToken.Parse(json);
|
||||
if (obj is not null)
|
||||
{
|
||||
return obj.Value<string>("Type") switch
|
||||
{
|
||||
nameof(TravelAgentPostConfiguration) => JsonConvert.DeserializeObject<TravelAgentPostConfiguration>(json)!,
|
||||
nameof(ChiefPostConfiguration) => JsonConvert.DeserializeObject<ChiefPostConfiguration>(json)!,
|
||||
_ => JsonConvert.DeserializeObject<PostConfiguration>(json)!,
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.BindingModels;
|
||||
|
||||
public class SaleBindingModel
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
|
||||
public string? EmployeeId { get; set; }
|
||||
|
||||
public string? ClientId { get; set; }
|
||||
|
||||
public int DiscountType { get; set; }
|
||||
|
||||
public List<SaleTourBindingModel>? Tours { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.BindingModels;
|
||||
|
||||
public class SaleTourBindingModel
|
||||
{
|
||||
public string? SaleId { get; set; }
|
||||
|
||||
public string? TourId { 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 MagicCarpetContracts.BindingModels;
|
||||
|
||||
public class TourBindingModel
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public string? TourName { get; set; }
|
||||
public string? TourCountry { get; set; }
|
||||
public double Price { get; set; }
|
||||
public string? TourType { get; set; }
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using MagicCarpetContracts.DataModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.BusinessLogicContracts;
|
||||
|
||||
public interface IAgencyBusinessLogicContract
|
||||
{
|
||||
List<AgencyDataModel> GetAllComponents();
|
||||
AgencyDataModel GetComponentByData(string data);
|
||||
void InsertComponent(AgencyDataModel agencyDataModel);
|
||||
void UpdateComponent(AgencyDataModel agencyDataModel);
|
||||
void DeleteComponent(string id);
|
||||
}
|
||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.BuisnessLogicContracts;
|
||||
|
||||
public interface IClientBusinessLogicContract
|
||||
internal interface IClientBusinessLogicContract
|
||||
{
|
||||
List<ClientDataModel> GetAllClients();
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.BuisnessLogicContracts;
|
||||
|
||||
public interface IEmployeeBusinessLogicContract
|
||||
internal interface IEmployeeBusinessLogicContract
|
||||
{
|
||||
List<EmployeeDataModel> GetAllEmployees(bool onlyActive = true);
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.BuisnessLogicContracts;
|
||||
|
||||
public interface IPostBusinessLogicContract
|
||||
internal interface IPostBusinessLogicContract
|
||||
{
|
||||
List<PostDataModel> GetAllPosts(bool onlyActive);
|
||||
List<PostDataModel> GetAllPosts();
|
||||
|
||||
List<PostDataModel> GetAllDataOfPost(string postId);
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using MagicCarpetContracts.DataModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.BusinessLogicContracts;
|
||||
|
||||
internal interface IReportContract
|
||||
{
|
||||
Task<List<TourAndTourHistoryDataModel>> GetDataToursHistoryAsync(CancellationToken ct);
|
||||
Task<Stream> CreateDocumentToursHistoryAsync(CancellationToken ct);
|
||||
Task<List<SaleDataModel>> GetDataBySalesAsync(DateTime dateStart, DateTime dateFinish, CancellationToken ct);
|
||||
Task<Stream> CreateDocumentSalesByPeriodAsync(DateTime dateStart, DateTime dateFinish, CancellationToken ct);
|
||||
Task<List<EmployeeSalaryByPeriodDataModel>> GetDataSalaryByPeriodAsync(DateTime dateStart, DateTime dateFinish, CancellationToken ct);
|
||||
Task<Stream> CreateDocumentSalaryByPeriodAsync(DateTime dateStart, DateTime dateFinish, CancellationToken ct);
|
||||
}
|
||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.BuisnessLogicContracts;
|
||||
|
||||
public interface ISalaryBusinessLogicContract
|
||||
internal interface ISalaryBusinessLogicContract
|
||||
{
|
||||
List<SalaryDataModel> GetAllSalariesByPeriod(DateTime fromDate, DateTime toDate);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.BuisnessLogicContracts;
|
||||
|
||||
public interface ISaleBusinessLogicContract
|
||||
internal interface ISaleBusinessLogicContract
|
||||
{
|
||||
List<SaleDataModel> GetAllSalesByPeriod(DateTime fromDate, DateTime toDate);
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
using MagicCarpetContracts.DataModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.BusinessLogicContracts;
|
||||
|
||||
public interface ISuppliesBusinessLogicContract
|
||||
{
|
||||
List<SuppliesDataModel> GetAllComponents();
|
||||
SuppliesDataModel GetComponentByData(string data);
|
||||
void InsertComponent(SuppliesDataModel componentDataModel);
|
||||
void UpdateComponent(SuppliesDataModel componentDataModel);
|
||||
}
|
||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.BuisnessLogicContracts;
|
||||
|
||||
public interface ITourBusinessLogicContract
|
||||
internal interface ITourBusinessLogicContract
|
||||
{
|
||||
List<TourDataModel> GetAllTours();
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
using MagicCarpetContracts.Enums;
|
||||
using MagicCarpetContracts.Exceptions;
|
||||
using MagicCarpetContracts.Extensions;
|
||||
using MagicCarpetContracts.Infrastructure;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.DataModels;
|
||||
|
||||
public class AgencyDataModel(string id, TourType tourType, int count, List<TourAgencyDataModel> tours) : IValidation
|
||||
{
|
||||
public string Id { get; private set; } = id;
|
||||
public TourType Type { get; private set; } = tourType;
|
||||
public int Count { get; private set; } = count;
|
||||
public List<TourAgencyDataModel> Tours { get; private set; } = tours;
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
if (Id.IsEmpty())
|
||||
throw new ValidationException("Field Id is empty");
|
||||
if (!Id.IsGuid())
|
||||
throw new ValidationException("The value in the field Id is not a unique identifier");
|
||||
if (Type == TourType.None)
|
||||
throw new ValidationException("Field Type is empty");
|
||||
if (Count <= 0)
|
||||
throw new ValidationException("Field Count is less than or equal to 0");
|
||||
if ((Tours?.Count ?? 0) == 0)
|
||||
throw new ValidationException("The sale must include tours");
|
||||
}
|
||||
}
|
||||
@@ -9,10 +9,12 @@ using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using ValidationException = MagicCarpetContracts.Exceptions.ValidationException;
|
||||
using MagicCarpetContracts.Resources;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace MagicCarpetContracts.DataModels;
|
||||
|
||||
public class ClientDataModel(string id, string fIO, string phoneNumber, double discountSize) : IValidation
|
||||
internal class ClientDataModel(string id, string fIO, string phoneNumber, double discountSize) : IValidation
|
||||
{
|
||||
public string Id { get; private set; } = id;
|
||||
|
||||
@@ -22,21 +24,23 @@ public class ClientDataModel(string id, string fIO, string phoneNumber, double d
|
||||
|
||||
public double DiscountSize { get; private set; } = discountSize;
|
||||
|
||||
public void Validate()
|
||||
public ClientDataModel() : this(string.Empty, string.Empty, string.Empty, 0) { }
|
||||
|
||||
public void Validate(IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
if (Id.IsEmpty())
|
||||
throw new ValidationException("Field Id is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "Id"));
|
||||
|
||||
if (!Id.IsGuid())
|
||||
throw new ValidationException("The value in the field Id is not a unique identifier");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
|
||||
if (FIO.IsEmpty())
|
||||
throw new ValidationException("Field FIO is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "FIO"));
|
||||
|
||||
if (PhoneNumber.IsEmpty())
|
||||
throw new ValidationException("Field PhoneNumber is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "PhoneNumber"));
|
||||
|
||||
if (!Regex.IsMatch(PhoneNumber, @"^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$"))
|
||||
throw new ValidationException("Field PhoneNumber is not a phone number");
|
||||
throw new ValidationException(localizer["ValidationExceptionIncorrectPhoneNumber"]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using MagicCarpetContracts.Exceptions;
|
||||
using MagicCarpetContracts.Extensions;
|
||||
using MagicCarpetContracts.Infrastructure;
|
||||
using MagicCarpetContracts.Resources;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -10,8 +13,10 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.DataModels;
|
||||
|
||||
public class EmployeeDataModel(string id, string fio, string email, string postId, DateTime birthDate, DateTime employmentDate, bool isDeleted) : IValidation
|
||||
internal class EmployeeDataModel(string id, string fio, string email, string postId, DateTime birthDate, DateTime employmentDate, bool isDeleted) : IValidation
|
||||
{
|
||||
private readonly PostDataModel? _post;
|
||||
|
||||
public string Id { get; private set; } = id;
|
||||
|
||||
public string FIO { get; private set; } = fio;
|
||||
@@ -20,42 +25,57 @@ public class EmployeeDataModel(string id, string fio, string email, string postI
|
||||
|
||||
public string PostId { get; private set; } = postId;
|
||||
|
||||
public DateTime BirthDate { get; private set; } = birthDate;
|
||||
public DateTime BirthDate { get; private set; } = birthDate.ToUniversalTime();
|
||||
|
||||
public DateTime EmploymentDate { get; private set; } = employmentDate;
|
||||
public DateTime EmploymentDate { get; private set; } = employmentDate.ToUniversalTime();
|
||||
|
||||
public bool IsDeleted { get; private set; } = isDeleted;
|
||||
|
||||
public void Validate()
|
||||
public string PostName => _post?.PostName ?? string.Empty;
|
||||
|
||||
public EmployeeDataModel(string id, string fio, string email, string postId, DateTime birthDate, DateTime employmentDate,
|
||||
bool isDeleted, PostDataModel post) : this(id, fio, email, postId, birthDate, employmentDate, isDeleted)
|
||||
{
|
||||
_post = post;
|
||||
}
|
||||
|
||||
public EmployeeDataModel(string id, string fio, string email, string postId, DateTime birthDate,
|
||||
DateTime employmentDate) : this(id, fio, email, postId, birthDate, employmentDate, false) { }
|
||||
|
||||
public EmployeeDataModel() : this(string.Empty, string.Empty, string.Empty, string.Empty, DateTime.MinValue, DateTime.MinValue, false) { }
|
||||
|
||||
public void Validate(IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
if (Id.IsEmpty())
|
||||
throw new ValidationException("Field Id is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "Id"));
|
||||
|
||||
if (!Id.IsGuid())
|
||||
throw new ValidationException("The value in the field Id is not a unique identifier");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
|
||||
if (FIO.IsEmpty())
|
||||
throw new ValidationException("Field FIO is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "FIO"));
|
||||
|
||||
if (Email.IsEmpty())
|
||||
throw new ValidationException("Field Email is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "Email"));
|
||||
|
||||
if (!Regex.IsMatch(Email, @"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"))
|
||||
throw new ValidationException("Field Email is not a valid email address");
|
||||
throw new ValidationException(localizer["ValidationExceptionMessageIncorrectEmail"]);
|
||||
|
||||
if (PostId.IsEmpty())
|
||||
throw new ValidationException("Field PostId is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "PostId"));
|
||||
|
||||
if (!PostId.IsGuid())
|
||||
throw new ValidationException("The value in the field PostId is not a unique identifier");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "PostId"));
|
||||
|
||||
if (BirthDate.Date > DateTime.Now.AddYears(-18).Date)
|
||||
throw new ValidationException($"Only adults can be hired (BirthDate = {BirthDate.ToShortDateString()})");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageMinorsBirthDate"], BirthDate.ToShortDateString()));
|
||||
|
||||
if (EmploymentDate.Date < BirthDate.Date)
|
||||
throw new ValidationException("The date of employment cannot be less than the date of birth");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmploymentDateAndBirthDate"],
|
||||
EmploymentDate.ToShortDateString(), BirthDate.ToShortDateString()));
|
||||
|
||||
if ((EmploymentDate - BirthDate).TotalDays / 365 < 18)
|
||||
throw new ValidationException($"Only adults can be hired (EmploymentDate - {EmploymentDate.ToShortDateString()}, BirthDate - {BirthDate.ToShortDateString()})");
|
||||
if ((EmploymentDate - BirthDate).TotalDays / 365 < 18)
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageMinorsEmploymentDate"],
|
||||
EmploymentDate.ToShortDateString(), BirthDate.ToShortDateString()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.DataModels;
|
||||
|
||||
public class EmployeeSalaryByPeriodDataModel
|
||||
{
|
||||
public required string EmployeeFIO { get; set; }
|
||||
|
||||
public double TotalSalary { get; set; }
|
||||
|
||||
public DateTime FromPeriod { get; set; }
|
||||
|
||||
public DateTime ToPeriod { get; set; }
|
||||
}
|
||||
@@ -2,34 +2,82 @@
|
||||
using MagicCarpetContracts.Exceptions;
|
||||
using MagicCarpetContracts.Extensions;
|
||||
using MagicCarpetContracts.Infrastructure;
|
||||
using MagicCarpetContracts.Infrastructure.PostConfigurations;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MagicCarpetContracts.Resources;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using MagicCarpetContracts.Mapper;
|
||||
|
||||
namespace MagicCarpetContracts.DataModels;
|
||||
|
||||
public class PostDataModel(string id, string postName, PostType postType, double salary, bool isActual, DateTime changeDate) : IValidation
|
||||
internal class PostDataModel(string postId, string postName, PostType postType, PostConfiguration configuration) : IValidation
|
||||
{
|
||||
public string Id { get; private set; } = id;
|
||||
[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 bool IsActual { get; private set; } = isActual;
|
||||
public DateTime ChangeDate { get; private set; } = changeDate;
|
||||
|
||||
public void Validate()
|
||||
[AlternativeName("Configuration")]
|
||||
[AlternativeName("ConfigurationJson")]
|
||||
[PostProcessing(MappingCallMethodName = "ParseJson")]
|
||||
public PostConfiguration ConfigurationModel { get; private set; } = configuration;
|
||||
|
||||
public PostDataModel() : this(string.Empty, string.Empty, PostType.None, null) { }
|
||||
public PostDataModel(string postId, string postName) : this(postId, postName, PostType.None, new PostConfiguration() { Rate = 10 }) { }
|
||||
|
||||
public void Validate(IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
if (Id.IsEmpty())
|
||||
throw new ValidationException("Field Id is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "Id"));
|
||||
|
||||
if (!Id.IsGuid())
|
||||
throw new ValidationException("The value in the field Id is not a unique identifier");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
|
||||
if (PostName.IsEmpty())
|
||||
throw new ValidationException("Field PostName is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "PostName"));
|
||||
|
||||
if (PostType == PostType.None)
|
||||
throw new ValidationException("Field PostType is empty");
|
||||
if (Salary <= 0)
|
||||
throw new ValidationException("Field Salary is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "PostType"));
|
||||
|
||||
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(object json)
|
||||
{
|
||||
if (json is PostConfiguration config)
|
||||
{
|
||||
return config;
|
||||
}
|
||||
if (json is string)
|
||||
{
|
||||
|
||||
var obj = JToken.Parse((string)json);
|
||||
var type = obj.Value<string>("Type");
|
||||
switch (type)
|
||||
{
|
||||
case nameof(TravelAgentPostConfiguration):
|
||||
ConfigurationModel = JsonConvert.DeserializeObject<TravelAgentPostConfiguration>((string)json);
|
||||
break;
|
||||
case nameof(ChiefPostConfiguration):
|
||||
ConfigurationModel = JsonConvert.DeserializeObject<ChiefPostConfiguration>((string)json);
|
||||
break;
|
||||
default:
|
||||
ConfigurationModel = JsonConvert.DeserializeObject<PostConfiguration>((string)json);
|
||||
break;
|
||||
}
|
||||
return ConfigurationModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using MagicCarpetContracts.Exceptions;
|
||||
using MagicCarpetContracts.Extensions;
|
||||
using MagicCarpetContracts.Infrastructure;
|
||||
using MagicCarpetContracts.Mapper;
|
||||
using MagicCarpetContracts.Resources;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -9,23 +12,34 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.DataModels;
|
||||
|
||||
public class SalaryDataModel(string employeeId, DateTime salaryDate, double employeeSalary) : IValidation
|
||||
internal class SalaryDataModel(string employeeId, DateTime salaryDate, double employeeSalary) : IValidation
|
||||
{
|
||||
private readonly EmployeeDataModel? _employee;
|
||||
public string EmployeeId { get; private set; } = employeeId;
|
||||
|
||||
public DateTime SalaryDate { get; private set; } = salaryDate;
|
||||
public DateTime SalaryDate { get; private set; } = salaryDate.ToUniversalTime();
|
||||
|
||||
[AlternativeName("EmployeeSalary")]
|
||||
public double Salary { get; private set; } = employeeSalary;
|
||||
|
||||
public void Validate()
|
||||
public string EmployeeFIO => _employee?.FIO ?? string.Empty;
|
||||
|
||||
public SalaryDataModel(string employeeId, DateTime salaryDate, double employeeSalary, EmployeeDataModel employee) : this(employeeId, salaryDate, employeeSalary)
|
||||
{
|
||||
_employee = employee;
|
||||
}
|
||||
|
||||
public SalaryDataModel() : this(string.Empty, DateTime.Now, 0) { }
|
||||
|
||||
public void Validate(IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
if (EmployeeId.IsEmpty())
|
||||
throw new ValidationException("Field EmployeeId is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "EmployeeId"));
|
||||
|
||||
if (!EmployeeId.IsGuid())
|
||||
throw new ValidationException("The value in the field EmployeeId is not a unique identifier");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "EmployeeId"));
|
||||
|
||||
if (Salary <= 0)
|
||||
throw new ValidationException("Field Salary is less than or equal to 0");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageLessOrEqualZero"], "Salary"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
using MagicCarpetContracts.Exceptions;
|
||||
using MagicCarpetContracts.Extensions;
|
||||
using MagicCarpetContracts.Infrastructure;
|
||||
using MagicCarpetContracts.Mapper;
|
||||
using MagicCarpetContracts.Resources;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -10,47 +13,108 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.DataModels;
|
||||
|
||||
public class SaleDataModel(string id, string employeeId, string? clientId, double sum, DiscountType discountType,
|
||||
double discount, bool isCancel, List<SaleTourDataModel> saleTours) : IValidation
|
||||
internal class SaleDataModel : IValidation
|
||||
{
|
||||
public string Id { get; private set; } = id;
|
||||
private readonly ClientDataModel? _client;
|
||||
|
||||
public string EmployeeId { get; private set; } = employeeId;
|
||||
private readonly EmployeeDataModel? _employee;
|
||||
|
||||
public string? ClientId { get; private set; } = clientId;
|
||||
public string Id { get; private set; }
|
||||
|
||||
public string EmployeeId { get; private set; }
|
||||
|
||||
public string? ClientId { get; private set; }
|
||||
|
||||
public DateTime SaleDate { get; private set; } = DateTime.UtcNow;
|
||||
public double Sum { get; private set; } = sum;
|
||||
|
||||
public DiscountType DiscountType { get; private set; } = discountType;
|
||||
public double Sum { get; private set; }
|
||||
|
||||
public double Discount { get; private set; } = discount;
|
||||
public DiscountType DiscountType { get; private set; }
|
||||
|
||||
public bool IsCancel { get; private set; } = isCancel;
|
||||
public double Discount { get; private set; }
|
||||
|
||||
public List<SaleTourDataModel> Tours { get; private set; } = saleTours;
|
||||
public bool IsCancel { get; private set; }
|
||||
|
||||
public void Validate()
|
||||
[AlternativeName("SaleTours")]
|
||||
public List<SaleTourDataModel>? Tours { get; private set; }
|
||||
|
||||
public string ClientFIO => _client?.FIO ?? string.Empty;
|
||||
|
||||
public string EmployeeFIO => _employee?.FIO ?? string.Empty;
|
||||
|
||||
public SaleDataModel(string id, string employeeId, string? clientId, DiscountType discountType, bool isCancel, List<SaleTourDataModel> saleTours)
|
||||
{
|
||||
Id = id;
|
||||
EmployeeId = employeeId;
|
||||
ClientId = clientId;
|
||||
DiscountType = discountType;
|
||||
IsCancel = isCancel;
|
||||
Tours = saleTours;
|
||||
var percent = 0.0;
|
||||
foreach (DiscountType elem in Enum.GetValues<DiscountType>())
|
||||
{
|
||||
if ((elem & discountType) != 0)
|
||||
{
|
||||
switch (elem)
|
||||
{
|
||||
case DiscountType.None:
|
||||
break;
|
||||
case DiscountType.OnSale:
|
||||
percent += 0.1;
|
||||
break;
|
||||
case DiscountType.RegularCustomer:
|
||||
percent += 0.5;
|
||||
break;
|
||||
case DiscountType.Certificate:
|
||||
percent += 0.3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Sum = Tours?.Sum(x => x.Price * x.Count) ?? 0;
|
||||
Discount = Sum * percent;
|
||||
}
|
||||
|
||||
public SaleDataModel(string id, string employeeId, string? clientId, double sum, DiscountType discountType, double discount, bool isCancel,
|
||||
List<SaleTourDataModel> saleTours, EmployeeDataModel employee, ClientDataModel? client) : this(id, employeeId, clientId, discountType, isCancel, saleTours)
|
||||
{
|
||||
Sum = sum;
|
||||
Discount = discount;
|
||||
_employee = employee;
|
||||
_client = client;
|
||||
}
|
||||
|
||||
public SaleDataModel(string id, string employeeId, string? clientId, int discountType,
|
||||
List<SaleTourDataModel> tours) : this(id, employeeId, clientId, (DiscountType)discountType, false, tours) { }
|
||||
|
||||
public SaleDataModel() : this(string.Empty, string.Empty, string.Empty, DiscountType.None, false, new List<SaleTourDataModel>()) { }
|
||||
|
||||
public void Validate(IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
if (Id.IsEmpty())
|
||||
throw new ValidationException("Field Id is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "Id"));
|
||||
|
||||
if (!Id.IsGuid())
|
||||
throw new ValidationException("The value in the field Id is not a unique identifier");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
|
||||
if (EmployeeId.IsEmpty())
|
||||
throw new ValidationException("Field EmployeeId is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "WorkerId"));
|
||||
|
||||
if (!EmployeeId.IsGuid())
|
||||
throw new ValidationException("The value in the field EmployeeId is not a unique identifier");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "WorkerId"));
|
||||
|
||||
if (!ClientId?.IsGuid() ?? !ClientId?.IsEmpty() ?? false)
|
||||
throw new ValidationException("The value in the field BuyerId is not a unique identifier");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "BuyerId"));
|
||||
|
||||
if (Sum <= 0)
|
||||
throw new ValidationException("Field Sum is less than or equal to 0");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageLessOrEqualZero"], "Sum"));
|
||||
|
||||
if ((Tours?.Count ?? 0) == 0)
|
||||
throw new ValidationException("The sale must include tours");
|
||||
if (Tours is null)
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotInitialized"], "Tours"));
|
||||
|
||||
if (Tours.Count == 0)
|
||||
throw new ValidationException(localizer["ValidationExceptionMessageNoProductsInSale"]);
|
||||
|
||||
Tours.ForEach(x => x.Validate(localizer));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +1,56 @@
|
||||
using MagicCarpetContracts.Exceptions;
|
||||
using MagicCarpetContracts.Extensions;
|
||||
using MagicCarpetContracts.Infrastructure;
|
||||
using MagicCarpetContracts.Resources;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.DataModels;
|
||||
|
||||
public class SaleTourDataModel(string saleId, string tourId, int count) : IValidation
|
||||
internal class SaleTourDataModel(string saleId, string tourId, int count, double price) : IValidation
|
||||
{
|
||||
private readonly TourDataModel? _tour;
|
||||
|
||||
public string SaleId { get; private set; } = saleId;
|
||||
|
||||
public string TourId { get; private set; } = tourId;
|
||||
|
||||
public int Count { get; private set; } = count;
|
||||
|
||||
public void Validate()
|
||||
public double Price { get; private set; } = price;
|
||||
|
||||
public string TourName => _tour?.TourName ?? string.Empty;
|
||||
|
||||
public SaleTourDataModel() : this(string.Empty, string.Empty, 0, 0.0) { }
|
||||
|
||||
public SaleTourDataModel(string saleId, string tourId, int count, double price, TourDataModel tour) : this(saleId, tourId, count, price)
|
||||
{
|
||||
_tour = tour;
|
||||
}
|
||||
|
||||
public void Validate(IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
if (SaleId.IsEmpty())
|
||||
throw new ValidationException("Field SaleId is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "SaleId"));
|
||||
|
||||
if (!SaleId.IsGuid())
|
||||
throw new ValidationException("The value in the field SaleId is not a unique identifier");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "SaleId"));
|
||||
|
||||
if (TourId.IsEmpty())
|
||||
throw new ValidationException("Field ProductId is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "ITourIdd"));
|
||||
|
||||
if (!TourId.IsGuid())
|
||||
throw new ValidationException("The value in the field ProductId is not a unique identifier");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "TourId"));
|
||||
|
||||
if (Count <= 0)
|
||||
throw new ValidationException("Field Count is less than or equal to 0");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageLessOrEqualZero"], "Count"));
|
||||
|
||||
if (Price <= 0)
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageLessOrEqualZero"], "Price"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
using MagicCarpetContracts.Enums;
|
||||
using MagicCarpetContracts.Exceptions;
|
||||
using MagicCarpetContracts.Extensions;
|
||||
using MagicCarpetContracts.Infrastructure;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace MagicCarpetContracts.DataModels;
|
||||
|
||||
public class SuppliesDataModel(string id, TourType tourType, DateTime date, int count, List<TourSuppliesDataModel> tours) : IValidation
|
||||
{
|
||||
public string Id { get; private set; } = id;
|
||||
public TourType Type { get; private set; } = tourType;
|
||||
public DateTime ProductuionDate { get; private set; } = date;
|
||||
public int Count { get; private set; } = count;
|
||||
public List<TourSuppliesDataModel> Tours { get; private set; } = tours;
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
if (Id.IsEmpty())
|
||||
throw new ValidationException("Field Id is empty");
|
||||
if (!Id.IsGuid())
|
||||
throw new ValidationException("The value in the field Id is not a unique identifier");
|
||||
if (Type == TourType.None)
|
||||
throw new ValidationException("Field Type is empty");
|
||||
if (Count <= 0)
|
||||
throw new ValidationException("Field Count is less than or equal to 0");
|
||||
if ((Tours?.Count ?? 0) == 0)
|
||||
throw new ValidationException("The sale must include tours");
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
using MagicCarpetContracts.Exceptions;
|
||||
using MagicCarpetContracts.Extensions;
|
||||
using MagicCarpetContracts.Infrastructure;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.DataModels;
|
||||
|
||||
public class TourAgencyDataModel(string agencyId, string tourId, int count) : IValidation
|
||||
{
|
||||
public string AgencyId { get; private set; } = agencyId;
|
||||
public string TourId { get; private set; } = tourId;
|
||||
public int Count { get; private set; } = count;
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
if (AgencyId.IsEmpty())
|
||||
throw new ValidationException("Field AgencyId is empty");
|
||||
if (!AgencyId.IsGuid())
|
||||
throw new ValidationException("The value in the field AgencyId is not a unique identifier");
|
||||
if (TourId.IsEmpty())
|
||||
throw new ValidationException("Field TourId is empty");
|
||||
if (!TourId.IsGuid())
|
||||
throw new ValidationException("The value in the field TourId is not a unique identifier");
|
||||
if (Count <= 0)
|
||||
throw new ValidationException("Field Count is less than or equal to 0");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.DataModels;
|
||||
|
||||
public class TourAndTourHistoryDataModel
|
||||
{
|
||||
public required string TourName { get; set; }
|
||||
public required List<string> Histories { get; set; }
|
||||
public required List<string> Data { get; set; }
|
||||
}
|
||||
@@ -2,6 +2,8 @@
|
||||
using MagicCarpetContracts.Exceptions;
|
||||
using MagicCarpetContracts.Extensions;
|
||||
using MagicCarpetContracts.Infrastructure;
|
||||
using MagicCarpetContracts.Resources;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@@ -12,7 +14,7 @@ using System.Xml.Linq;
|
||||
|
||||
namespace MagicCarpetContracts.DataModels;
|
||||
|
||||
public class TourDataModel(string id, string tourName, string tourCountry, double price, TourType tourType) : IValidation
|
||||
internal class TourDataModel(string id, string tourName, string tourCountry, double price, TourType tourType) : IValidation
|
||||
{
|
||||
public string Id { get; private set; } = id;
|
||||
public string TourName { get; private set; } = tourName;
|
||||
@@ -20,19 +22,21 @@ public class TourDataModel(string id, string tourName, string tourCountry, doubl
|
||||
public double Price { get; private set; } = price;
|
||||
public TourType TourType { get; private set; } = tourType;
|
||||
|
||||
public void Validate()
|
||||
public TourDataModel() : this(string.Empty, string.Empty, string.Empty, 0, TourType.None) { }
|
||||
|
||||
public void Validate(IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
if (Id.IsEmpty())
|
||||
throw new ValidationException("Field Id is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "Id"));
|
||||
if (!Id.IsGuid())
|
||||
throw new ValidationException("The value in the field Id is not a unique identifier");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
if (TourName.IsEmpty())
|
||||
throw new ValidationException("Field TourName is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "TourName"));
|
||||
if (TourCountry.IsEmpty())
|
||||
throw new ValidationException("Field TourCountry is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "TourCountry"));
|
||||
if (Price <= 0)
|
||||
throw new ValidationException("Field Price is less than or equal to 0");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageLessOrEqualZero"], "Price"));
|
||||
if (TourType == TourType.None)
|
||||
throw new ValidationException("Field Type is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "TourType"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,40 @@
|
||||
using MagicCarpetContracts.Exceptions;
|
||||
using MagicCarpetContracts.Extensions;
|
||||
using MagicCarpetContracts.Infrastructure;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MagicCarpetContracts.Resources;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace MagicCarpetContracts.DataModels;
|
||||
|
||||
public class TourHistoryDataModel(string tourId, double oldPrice) : IValidation
|
||||
internal class TourHistoryDataModel(string tourId, double oldPrice) : IValidation
|
||||
{
|
||||
private readonly TourDataModel? _tour;
|
||||
|
||||
public string TourId { get; private set; } = tourId;
|
||||
|
||||
public double OldPrice { get; private set; } = oldPrice;
|
||||
|
||||
public DateTime ChangeDate { get; private set; } = DateTime.UtcNow;
|
||||
|
||||
public void Validate()
|
||||
public string TourName => _tour?.TourName ?? string.Empty;
|
||||
|
||||
public TourHistoryDataModel(string tourId, double oldPrice, DateTime changeDate, TourDataModel tour) : this(tourId, oldPrice)
|
||||
{
|
||||
ChangeDate = changeDate;
|
||||
_tour = tour;
|
||||
}
|
||||
|
||||
public TourHistoryDataModel() : this(string.Empty, 0) { }
|
||||
|
||||
public void Validate(IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
if (TourId.IsEmpty())
|
||||
throw new ValidationException("Field TourId is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "TourId"));
|
||||
|
||||
if (!TourId.IsGuid())
|
||||
throw new ValidationException("The value in the field TourId is not a unique identifier");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "TourId"));
|
||||
|
||||
if (OldPrice <= 0)
|
||||
throw new ValidationException("Field OldPrice is less than or equal to 0");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageLessOrEqualZero"], "OldPrice"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
using MagicCarpetContracts.Exceptions;
|
||||
using MagicCarpetContracts.Extensions;
|
||||
using MagicCarpetContracts.Infrastructure;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.DataModels;
|
||||
|
||||
public class TourSuppliesDataModel(string suppliesId, string tourId, int count) : IValidation
|
||||
{
|
||||
public string SuppliesId { get; private set; } = suppliesId;
|
||||
public string TourId { get; private set; } = tourId;
|
||||
public int Count { get; private set; } = count;
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
if (SuppliesId.IsEmpty())
|
||||
throw new ValidationException("Field SuppliesId is empty");
|
||||
if (!SuppliesId.IsGuid())
|
||||
throw new ValidationException("The value in the field SuppliesId is not a unique identifier");
|
||||
if (TourId.IsEmpty())
|
||||
throw new ValidationException("Field TourId is empty");
|
||||
if (!TourId.IsGuid())
|
||||
throw new ValidationException("The value in the field BlandId is not a unique identifier");
|
||||
if (Count <= 0)
|
||||
throw new ValidationException("Field Count is less than or equal to 0");
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using MagicCarpetContracts.Resources;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -6,7 +8,6 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.Exceptions;
|
||||
|
||||
public class ElementDeletedException : Exception
|
||||
{
|
||||
public ElementDeletedException(string id) : base($"Cannot modify a deleted item (id: {id})") { }
|
||||
}
|
||||
internal class ElementDeletedException(string id, IStringLocalizer<Messages> localizer)
|
||||
: Exception(string.Format(localizer["ElementDeletedExceptionMessage"], id))
|
||||
{ }
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using MagicCarpetContracts.Resources;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -6,15 +8,10 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.Exceptions;
|
||||
|
||||
public class ElementExistsException : Exception
|
||||
internal class ElementExistsException(string paramName, string paramValue, IStringLocalizer<Messages> localizer) :
|
||||
Exception(string.Format(localizer["ElementExistsExceptionMessage"], paramValue, paramName))
|
||||
{
|
||||
public string ParamName { get; private set; }
|
||||
public string ParamName { get; private set; } = paramName;
|
||||
|
||||
public string ParamValue { get; private set; }
|
||||
|
||||
public ElementExistsException(string paramName, string paramValue) : base($"There is already an element with value{paramValue} of parameter {paramName}")
|
||||
{
|
||||
ParamName = paramName;
|
||||
ParamValue = paramValue;
|
||||
}
|
||||
public string ParamValue { get; private set; } = paramValue;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using MagicCarpetContracts.Resources;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -6,12 +8,8 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.Exceptions;
|
||||
|
||||
public class ElementNotFoundException : Exception
|
||||
internal class ElementNotFoundException(string value, IStringLocalizer<Messages> localizer) :
|
||||
Exception(string.Format(localizer["AdapterMessageElementNotFoundException"], value))
|
||||
{
|
||||
public string Value { get; private set; }
|
||||
|
||||
public ElementNotFoundException(string value) : base($"Element not found at value = {value}")
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
public string Value { get; private set; } = value;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using MagicCarpetContracts.Resources;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -6,8 +8,6 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.Exceptions;
|
||||
|
||||
public class IncorrectDatesException : Exception
|
||||
{
|
||||
public IncorrectDatesException(DateTime start, DateTime end) : base($"The end date must be later than the start date.. StartDate: " +
|
||||
$"{start:dd.MM.YYYY}. EndDate: {end:dd.MM.YYYY}") { }
|
||||
}
|
||||
internal class IncorrectDatesException(DateTime start, DateTime end, IStringLocalizer<Messages> localizer) :
|
||||
Exception(string.Format(localizer["IncorrectDatesExceptionMessage"], start.ToShortDateString(), end.ToShortDateString()))
|
||||
{ }
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.Exceptions;
|
||||
|
||||
public class InsufficientException(string message) : Exception(message)
|
||||
{
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.Exceptions;
|
||||
|
||||
public class NullListException : Exception
|
||||
{
|
||||
public NullListException() : base("The returned list is null") { }
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using MagicCarpetContracts.Resources;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -6,7 +8,5 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.Exceptions;
|
||||
|
||||
public class StorageException : Exception
|
||||
{
|
||||
public StorageException(Exception ex) : base($"Error while working in storage: {ex.Message}", ex) { }
|
||||
}
|
||||
internal class StorageException(Exception ex, IStringLocalizer<Messages> localizer) : Exception(string.Format(localizer["StorageExceptionMessage"], ex.Message), ex)
|
||||
{ }
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.Infrastructure;
|
||||
|
||||
public interface IConfigurationSalary
|
||||
{
|
||||
double ExtraSaleSum { get; }
|
||||
|
||||
int MaxConcurrentThreads { get; }
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using MagicCarpetContracts.Resources;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -6,8 +8,8 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.Infrastructure;
|
||||
|
||||
public interface IValidation
|
||||
internal interface IValidation
|
||||
{
|
||||
void Validate();
|
||||
void Validate(IStringLocalizer<Messages> localizer);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.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,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.Infrastructure.PostConfigurations;
|
||||
|
||||
public class ChiefPostConfiguration : PostConfiguration
|
||||
{
|
||||
public override string Type => nameof(ChiefPostConfiguration);
|
||||
public double PersonalCountTrendPremium { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.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,15 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.Infrastructure.PostConfigurations;
|
||||
|
||||
public class TravelAgentPostConfiguration : PostConfiguration
|
||||
{
|
||||
public override string Type => nameof(TravelAgentPostConfiguration);
|
||||
public double SalePercent { get; set; }
|
||||
public double BonusForExtraSales { get; set; }
|
||||
}
|
||||
@@ -6,4 +6,18 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.3.0" />
|
||||
<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="MagicCarpetDatabase" />
|
||||
<InternalsVisibleTo Include="MagicCarpetTests" />
|
||||
<InternalsVisibleTo Include="MagicCarpetBusinessLogic" />
|
||||
<InternalsVisibleTo Include="MagicCarpetWebApi" />
|
||||
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace MagicCarpetContracts.Mapper;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true)]
|
||||
public class AlternativeNameAttribute : Attribute
|
||||
{
|
||||
public string AlternativeName { get; }
|
||||
|
||||
public AlternativeNameAttribute(string alternativeName)
|
||||
{
|
||||
AlternativeName = alternativeName;
|
||||
}
|
||||
}
|
||||
281
MagicCarpetProject/MagicCarpetContracts/Mapper/CustomMapper.cs
Normal file
281
MagicCarpetProject/MagicCarpetContracts/Mapper/CustomMapper.cs
Normal file
@@ -0,0 +1,281 @@
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
|
||||
namespace MagicCarpetContracts.Mapper;
|
||||
|
||||
internal 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.Name.StartsWith("List") && fromValue is not null)
|
||||
{
|
||||
fromValue = MapListOfObjects(property, fromValue);
|
||||
}
|
||||
|
||||
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 = Enum.Parse(property.PropertyType, stringValue);
|
||||
else
|
||||
fromValue = 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
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(postProcessingAttribute.MappingCallMethodName))
|
||||
{
|
||||
var methodInfo =
|
||||
newObject.GetType().GetMethod(postProcessingAttribute.MappingCallMethodName, BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
if (methodInfo is not null)
|
||||
{
|
||||
return methodInfo.Invoke(newObject, [value]);
|
||||
}
|
||||
}
|
||||
else if (postProcessingAttribute.ActionType != PostProcessingType.None)
|
||||
{
|
||||
switch (postProcessingAttribute.ActionType)
|
||||
{
|
||||
case PostProcessingType.ToUniversalTime:
|
||||
return ToUniversalTime(value);
|
||||
case PostProcessingType.ToLocalTime:
|
||||
return ToLocalTime(value);
|
||||
}
|
||||
}
|
||||
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 elementType = propertyTo.PropertyType.GenericTypeArguments[0];
|
||||
|
||||
foreach (var elem in (IEnumerable)list)
|
||||
{
|
||||
object? newElem;
|
||||
|
||||
if (elementType.IsPrimitive || elementType == typeof(string) || elementType == typeof(decimal) || elementType == typeof(DateTime))
|
||||
{
|
||||
newElem = elem;
|
||||
}
|
||||
else
|
||||
{
|
||||
newElem = MapObject(elem, Activator.CreateInstance(elementType)!);
|
||||
}
|
||||
|
||||
if (newElem is not null)
|
||||
{
|
||||
propertyTo.PropertyType.GetMethod("Add")!.Invoke(listResult, [newElem]);
|
||||
}
|
||||
}
|
||||
|
||||
return listResult;
|
||||
}
|
||||
}
|
||||
|
||||
enum DefaultValueFunc
|
||||
{
|
||||
None,
|
||||
UtcNow
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace MagicCarpetContracts.Mapper;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class)]
|
||||
class DefaultValueAttribute : Attribute
|
||||
{
|
||||
public object? DefaultValue { get; set; }
|
||||
|
||||
public string? FuncName { get; set; }
|
||||
|
||||
public DefaultValueFunc Func { get; set; } = DefaultValueFunc.None;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace MagicCarpetContracts.Mapper;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
class IgnoreMappingAttribute : Attribute
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace MagicCarpetContracts.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 MagicCarpetContracts.Mapper;
|
||||
|
||||
enum PostProcessingType
|
||||
{
|
||||
None = -1,
|
||||
|
||||
ToUniversalTime = 1,
|
||||
|
||||
ToLocalTime = 2
|
||||
}
|
||||
225
MagicCarpetProject/MagicCarpetContracts/Resources/Messages.Designer.cs
generated
Normal file
225
MagicCarpetProject/MagicCarpetContracts/Resources/Messages.Designer.cs
generated
Normal file
@@ -0,0 +1,225 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace MagicCarpetContracts.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("MagicCarpetContracts.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 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}.
|
||||
/// </summary>
|
||||
internal static string StorageExceptionMessage {
|
||||
get {
|
||||
return ResourceManager.GetString("StorageExceptionMessage", 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>
|
||||
/// Ищет локализованную строку, похожую на Некорректный формат ФИО.
|
||||
/// </summary>
|
||||
internal static string ValidationExceptionMessageIncorrectFIO {
|
||||
get {
|
||||
return ResourceManager.GetString("ValidationExceptionMessageIncorrectFIO", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Значение в поле Телефонный номер не является телефонным номером.
|
||||
/// </summary>
|
||||
internal static string ValidationExceptionMessageIncorrectPhoneNumber {
|
||||
get {
|
||||
return ResourceManager.GetString("ValidationExceptionMessageIncorrectPhoneNumber", 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 ValidationExceptionMessageNoComponents {
|
||||
get {
|
||||
return ResourceManager.GetString("ValidationExceptionMessageNoComponents", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на В продаже должен быть хотя бы один товар.
|
||||
/// </summary>
|
||||
internal static string ValidationExceptionMessageNoProductsInSale {
|
||||
get {
|
||||
return ResourceManager.GetString("ValidationExceptionMessageNoProductsInSale", 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,243 @@
|
||||
<?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>The item according to the data: {0} has been 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>Date</value>
|
||||
</data>
|
||||
<data name="DocumentDocCaptionPreviousNames" xml:space="preserve">
|
||||
<value>Previous names</value>
|
||||
</data>
|
||||
<data name="DocumentDocCaptionTour" xml:space="preserve">
|
||||
<value>Tour</value>
|
||||
</data>
|
||||
<data name="DocumentDocHeader" xml:space="preserve">
|
||||
<value>The history of tour changes</value>
|
||||
</data>
|
||||
<data name="DocumentDocSubHeader" xml:space="preserve">
|
||||
<value>Make In Date {0}</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionCount" xml:space="preserve">
|
||||
<value>Count</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionDate" xml:space="preserve">
|
||||
<value>Date</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionDiscount" xml:space="preserve">
|
||||
<value>Discount</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionSum" xml:space="preserve">
|
||||
<value>Sum</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionTotal" xml:space="preserve">
|
||||
<value>Total</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionTour" xml:space="preserve">
|
||||
<value>Tour</value>
|
||||
</data>
|
||||
<data name="DocumentExcelHeader" xml:space="preserve">
|
||||
<value>Sales for the period</value>
|
||||
</data>
|
||||
<data name="DocumentExcelHeaderEmployee" xml:space="preserve">
|
||||
<value>Employee</value>
|
||||
</data>
|
||||
<data name="DocumentExcelSubHeader" xml:space="preserve">
|
||||
<value>from {0} to {1}</value>
|
||||
</data>
|
||||
<data name="DocumentPdfDiagramCaption" xml:space="preserve">
|
||||
<value>Accruals</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="StorageExceptionMessage" xml:space="preserve">
|
||||
<value>Error while working in storage: {0}</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="ValidationExceptionMessageIncorrectFIO" xml:space="preserve">
|
||||
<value>Fio is not correct</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageIncorrectPhoneNumber" xml:space="preserve">
|
||||
<value>The value in the Phone Number field is not a phone number.</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="ValidationExceptionMessageNoProductsInSale" xml:space="preserve">
|
||||
<value>There must be at least one product on sale.</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>
|
||||
243
MagicCarpetProject/MagicCarpetContracts/Resources/Messages.resx
Normal file
243
MagicCarpetProject/MagicCarpetContracts/Resources/Messages.resx
Normal file
@@ -0,0 +1,243 @@
|
||||
<?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="DocumentDocCaptionPreviousNames" xml:space="preserve">
|
||||
<value>Предыдущие названия</value>
|
||||
</data>
|
||||
<data name="DocumentDocCaptionTour" 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="DocumentExcelCaptionDiscount" 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="DocumentExcelCaptionTour" xml:space="preserve">
|
||||
<value>Товар</value>
|
||||
</data>
|
||||
<data name="DocumentExcelHeader" xml:space="preserve">
|
||||
<value>Продажи за период</value>
|
||||
</data>
|
||||
<data name="DocumentExcelHeaderEmployee" 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="StorageExceptionMessage" xml:space="preserve">
|
||||
<value>Ошибка при работе в хранилище: {0}</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="ValidationExceptionMessageIncorrectFIO" xml:space="preserve">
|
||||
<value>Некорректный формат ФИО</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageIncorrectPhoneNumber" 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="ValidationExceptionMessageNoProductsInSale" 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>
|
||||
@@ -0,0 +1,243 @@
|
||||
<?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="DocumentDocCaptionPreviousNames" xml:space="preserve">
|
||||
<value>以前的名字</value>
|
||||
</data>
|
||||
<data name="DocumentDocCaptionTour" 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="DocumentExcelCaptionDiscount" 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="DocumentExcelCaptionTour" xml:space="preserve">
|
||||
<value>旅游</value>
|
||||
</data>
|
||||
<data name="DocumentExcelHeader" xml:space="preserve">
|
||||
<value>期间的销售额</value>
|
||||
</data>
|
||||
<data name="DocumentExcelHeaderEmployee" xml:space="preserve">
|
||||
<value>工人</value>
|
||||
</data>
|
||||
<data name="DocumentExcelSubHeader" xml:space="preserve">
|
||||
<value>从{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>无法更改已删除的项目(id:{0})</value>
|
||||
</data>
|
||||
<data name="ElementExistsExceptionMessage" xml:space="preserve">
|
||||
<value>已经有一个具有参数{1}的值{0}的元素</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="StorageExceptionMessage" xml:space="preserve">
|
||||
<value>在存储中工作时出错:{0}</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="ValidationExceptionMessageIncorrectFIO" xml:space="preserve">
|
||||
<value>名称格式不正确</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageIncorrectPhoneNumber" 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="ValidationExceptionMessageNoProductsInSale" 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>
|
||||
@@ -1,18 +0,0 @@
|
||||
using MagicCarpetContracts.DataModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.StoragesContracts;
|
||||
|
||||
public interface IAgencyStorageContract
|
||||
{
|
||||
List<AgencyDataModel> GetList();
|
||||
AgencyDataModel GetElementById(string id);
|
||||
void AddElement(AgencyDataModel agencyDataModel);
|
||||
void UpdElement(AgencyDataModel agencyDataModel);
|
||||
void DelElement(string id);
|
||||
bool CheckComponents(SaleDataModel saleDataModel);
|
||||
}
|
||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.StoragesContracts;
|
||||
|
||||
public interface IClientStorageContract
|
||||
internal interface IClientStorageContract
|
||||
{
|
||||
List<ClientDataModel> GetList();
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.StoragesContracts;
|
||||
|
||||
public interface IEmployeeStorageContract
|
||||
internal interface IEmployeeStorageContract
|
||||
{
|
||||
List<EmployeeDataModel> GetList(bool onlyActive = true, string? postId = null, DateTime? fromBirthDate = null,
|
||||
DateTime? toBirthDate = null, DateTime? fromEmploymentDate = null, DateTime? toEmploymentDate = null);
|
||||
@@ -23,4 +23,6 @@ public interface IEmployeeStorageContract
|
||||
void UpdElement(EmployeeDataModel employeeDataModel);
|
||||
|
||||
void DelElement(string id);
|
||||
|
||||
int GetEmployeeTrend(DateTime fromPeriod, DateTime toPeriod);
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.StoragesContracts;
|
||||
|
||||
public interface IPostStorageContract
|
||||
internal interface IPostStorageContract
|
||||
{
|
||||
List<PostDataModel> GetList(bool onlyActual = true);
|
||||
List<PostDataModel> GetList();
|
||||
List<PostDataModel> GetPostWithHistory(string postId);
|
||||
PostDataModel? GetElementById(string id);
|
||||
PostDataModel? GetElementByName(string name);
|
||||
|
||||
@@ -7,9 +7,11 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.StoragesContracts;
|
||||
|
||||
public interface ISalaryStorageContract
|
||||
internal interface ISalaryStorageContract
|
||||
{
|
||||
List<SalaryDataModel> GetList(DateTime startDate, DateTime endDate, string? employeeId = null);
|
||||
List<SalaryDataModel> GetList(DateTime? startDate, DateTime? endDate, string? employeeId = null);
|
||||
|
||||
Task<List<SalaryDataModel>> GetListAsync(DateTime startDate, DateTime endDate, CancellationToken ct);
|
||||
|
||||
void AddElement(SalaryDataModel salaryDataModel);
|
||||
}
|
||||
|
||||
@@ -7,11 +7,13 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.StoragesContracts;
|
||||
|
||||
public interface ISaleStorageContract
|
||||
internal interface ISaleStorageContract
|
||||
{
|
||||
List<SaleDataModel> GetList(DateTime? startDate = null, DateTime? endDate = null, string? employeeId = null,
|
||||
string? clientId = null, string? tourId = null);
|
||||
|
||||
Task<List<SaleDataModel>> GetListAsync(DateTime startDate, DateTime endDate, CancellationToken ct);
|
||||
|
||||
SaleDataModel? GetElementById(string id);
|
||||
|
||||
void AddElement(SaleDataModel saleDataModel);
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
using MagicCarpetContracts.DataModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.StoragesContracts;
|
||||
|
||||
public interface ISuppliesStorageContract
|
||||
{
|
||||
List<SuppliesDataModel> GetList(DateTime? startDate = null);
|
||||
SuppliesDataModel GetElementById(string id);
|
||||
void AddElement(SuppliesDataModel suppliesDataModel);
|
||||
void UpdElement(SuppliesDataModel suppliesDataModel);
|
||||
}
|
||||
@@ -7,10 +7,11 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.StoragesContracts;
|
||||
|
||||
public interface ITourStorageContract
|
||||
internal interface ITourStorageContract
|
||||
{
|
||||
List<TourDataModel> GetList();
|
||||
List<TourHistoryDataModel> GetHistoryByTourId(string tourId);
|
||||
Task<List<TourHistoryDataModel>> GetHistoriesListAsync(CancellationToken ct);
|
||||
TourDataModel? GetElementById(string id);
|
||||
TourDataModel? GetElementByName(string name);
|
||||
void AddElement(TourDataModel tourDataModel);
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.ViewModels;
|
||||
|
||||
public class ClientViewModel
|
||||
{
|
||||
public required string Id { get; set; }
|
||||
|
||||
public required string FIO { get; set; }
|
||||
|
||||
public required string PhoneNumber { get; set; }
|
||||
|
||||
public double DiscountSize { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.ViewModels;
|
||||
|
||||
public class EmployeeSalaryByPeriodViewModel
|
||||
{
|
||||
public required string EmployeeFIO { get; set; }
|
||||
public double TotalSalary { get; set; }
|
||||
public DateTime FromPeriod { get; set; }
|
||||
public DateTime ToPeriod { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using MagicCarpetContracts.Mapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.ViewModels;
|
||||
|
||||
public class EmployeeViewModel
|
||||
{
|
||||
[AlternativeName("EmployeeId")]
|
||||
public required string Id { get; set; }
|
||||
|
||||
public required string FIO { get; set; }
|
||||
|
||||
public string Email { get; set; }
|
||||
|
||||
public required string PostId { get; set; }
|
||||
|
||||
public required string PostName { get; set; }
|
||||
|
||||
public bool IsDeleted { get; set; }
|
||||
|
||||
[PostProcessing(ActionType = PostProcessingType.ToLocalTime)]
|
||||
public DateTime BirthDate { get; set; }
|
||||
|
||||
[PostProcessing(ActionType = PostProcessingType.ToLocalTime)]
|
||||
public DateTime EmploymentDate { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using MagicCarpetContracts.Infrastructure.PostConfigurations;
|
||||
using MagicCarpetContracts.Mapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.ViewModels;
|
||||
|
||||
public class PostViewModel
|
||||
{
|
||||
[AlternativeName("PostId")]
|
||||
public required string Id { get; set; }
|
||||
|
||||
public required string PostName { get; set; }
|
||||
|
||||
public required string PostType { get; set; }
|
||||
|
||||
[AlternativeName("ConfigurationModel")]
|
||||
[PostProcessing(MappingCallMethodName = "ParseConfiguration")]
|
||||
public required string Configuration { get; set; }
|
||||
|
||||
private string ParseConfiguration(PostConfiguration? model)
|
||||
{
|
||||
if (model == null)
|
||||
return string.Empty;
|
||||
|
||||
return JsonSerializer.Serialize(model, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using MagicCarpetContracts.Mapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.ViewModels;
|
||||
|
||||
public class SalaryViewModel
|
||||
{
|
||||
public required string EmployeeId { get; set; }
|
||||
public required string EmployeeFIO { get; set; }
|
||||
public DateTime SalaryDate { get; set; }
|
||||
|
||||
[AlternativeName("EmployeeSalary")]
|
||||
public double Salary { get; set; }
|
||||
}
|
||||
@@ -4,13 +4,15 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetDatabase.Models;
|
||||
namespace MagicCarpetContracts.ViewModels;
|
||||
|
||||
public class TourAgency
|
||||
public class SaleTourViewModel
|
||||
{
|
||||
public required string AgencyId { get; set; }
|
||||
public required string TourId { get; set; }
|
||||
|
||||
public required string TourName { get; set; }
|
||||
|
||||
public int Count { get; set; }
|
||||
public Agency? Agencies { get; set; }
|
||||
public Tour? Tours { get; set; }
|
||||
|
||||
public double Price { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using MagicCarpetContracts.Mapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.ViewModels;
|
||||
|
||||
public class SaleViewModel
|
||||
{
|
||||
public required string Id { get; set; }
|
||||
|
||||
public required string EmployeeId { get; set; }
|
||||
|
||||
public required string EmployeeFIO { get; set; }
|
||||
|
||||
public string? ClientId { get; set; }
|
||||
|
||||
public string? ClientFIO { get; set; }
|
||||
|
||||
[PostProcessing(ActionType = PostProcessingType.ToLocalTime)]
|
||||
public DateTime SaleDate { get; set; }
|
||||
|
||||
public double Sum { get; set; }
|
||||
|
||||
public required string DiscountType { get; set; }
|
||||
|
||||
public double Discount { get; set; }
|
||||
|
||||
public bool IsCancel { get; set; }
|
||||
|
||||
public required List<SaleTourViewModel> Tours { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.ViewModels;
|
||||
|
||||
public class TourAndTourHistoryViewModel
|
||||
{
|
||||
public required string TourName { get; set; }
|
||||
public required List<string> Histories { get; set; }
|
||||
public required List<string> Data { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MagicCarpetContracts.ViewModels;
|
||||
|
||||
public class TourHistoryViewModel
|
||||
{
|
||||
public required string TourName { get; set; }
|
||||
|
||||
public double OldPrice { get; set; }
|
||||
|
||||
public DateTime ChangeDate { get; set; }
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user