заготовки реализаций
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using SmallSoftwareContracts.BusinessLogicsContracts;
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
using SmallSoftwareContracts.StoragesContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace SmallSoftwareBusinessLogic.Implementations;
|
||||
|
||||
internal class ManufacturerBusinessLogicContract(IManufacturerStorageContract manufacturerStorageContract, ILogger logger) : IManufacturerBusinessLogicContract
|
||||
{
|
||||
private readonly ILogger _logger = logger;
|
||||
private readonly IManufacturerStorageContract _manufacturerStorageContract
|
||||
= manufacturerStorageContract;
|
||||
public List<ManufacturerDataModel> GetAllManufacturers()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
public ManufacturerDataModel GetManufacturerByData(string data)
|
||||
{
|
||||
return new("", "", "", "'");
|
||||
}
|
||||
public void InsertManufacturer(ManufacturerDataModel manufacturerDataModel)
|
||||
{
|
||||
}
|
||||
public void UpdateManufacturer(ManufacturerDataModel manufacturerDataModel)
|
||||
{
|
||||
}
|
||||
public void DeleteManufacturer(string id)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SmallSoftwareContracts.BusinessLogicsContracts;
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
using SmallSoftwareContracts.Enums;
|
||||
using SmallSoftwareContracts.StoragesContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareBusinessLogic.Implementations;
|
||||
|
||||
internal class PostBusinessLogicContract(IPostStorageContract postStorageContract, ILogger logger) : IPostBusinessLogicContract
|
||||
{
|
||||
private readonly ILogger _logger = logger;
|
||||
private readonly IPostStorageContract _postStorageContract =
|
||||
postStorageContract;
|
||||
public List<PostDataModel> GetAllPosts(bool onlyActive = true)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
public List<PostDataModel> GetAllDataOfPost(string postId)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
public PostDataModel GetPostByData(string data)
|
||||
{
|
||||
return new("", "", PostType.None, 0, true, DateTime.UtcNow);
|
||||
}
|
||||
public void InsertPost(PostDataModel postDataModel)
|
||||
{
|
||||
}
|
||||
public void UpdatePost(PostDataModel postDataModel)
|
||||
{
|
||||
}
|
||||
public void DeletePost(string id)
|
||||
{
|
||||
}
|
||||
public void RestorePost(string id)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SmallSoftwareContracts.BusinessLogicsContracts;
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
using SmallSoftwareContracts.StoragesContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareBusinessLogic.Implementations;
|
||||
|
||||
internal class RequestBusinessLogicContract(IRequestStorageContract requestStorageContract, ILogger logger) : IRequestBusinessLogicContract
|
||||
{
|
||||
private readonly ILogger _logger = logger;
|
||||
private readonly IRequestStorageContract _requestStorageContract =
|
||||
requestStorageContract;
|
||||
public List<RequestDataModel> GetAllRequestsByPeriod(DateTime fromDate, DateTime
|
||||
toDate)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
public List<RequestDataModel> GetAllRequestsByWorkerByPeriod(string workerId,
|
||||
DateTime fromDate, DateTime toDate)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
public List<RequestDataModel> GetAllRequestsByBuyerByPeriod(string? buyerId,
|
||||
DateTime fromDate, DateTime toDate)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
public List<RequestDataModel> GetAllRequestsByProductByPeriod(string productId,
|
||||
DateTime fromDate, DateTime toDate)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
public RequestDataModel GetRequestByData(string data)
|
||||
{
|
||||
return new("", "", "", 0, false, []);
|
||||
}
|
||||
public void InsertRequest(RequestDataModel requestDataModel)
|
||||
{
|
||||
}
|
||||
public void CancelRequest(string id)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SmallSoftwareContracts.BusinessLogicsContracts;
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
using SmallSoftwareContracts.StoragesContracts;
|
||||
namespace SmallSoftwareBusinessLogic.Implementations;
|
||||
|
||||
|
||||
internal class SalaryBusinessLogicContract(ISalaryStorageContract salaryStorageContract,
|
||||
IRequestStorageContract requestStorageContract, IPostStorageContract postStorageContract,
|
||||
IWorkerStorageContract workerStorageContract, ILogger logger) : ISalaryBusinessLogicContract
|
||||
{
|
||||
private readonly ILogger _logger = logger;
|
||||
private readonly ISalaryStorageContract _salaryStorageContract =
|
||||
salaryStorageContract;
|
||||
private readonly IRequestStorageContract _requestStorageContract =
|
||||
requestStorageContract;
|
||||
private readonly IPostStorageContract _postStorageContract =
|
||||
postStorageContract;
|
||||
private readonly IWorkerStorageContract _workerStorageContract =
|
||||
workerStorageContract;
|
||||
public List<SalaryDataModel> GetAllSalariesByPeriod(DateTime fromDate, DateTime toDate)
|
||||
|
||||
{
|
||||
return [];
|
||||
}
|
||||
public List<SalaryDataModel> GetAllSalariesByPeriodByWorker(DateTime fromDate, DateTime toDate, string workerId)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public void CalculateSalaryByMonth(DateTime date)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SmallSoftwareContracts.BusinessLogicsContracts;
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
using SmallSoftwareContracts.Enums;
|
||||
using SmallSoftwareContracts.StoragesContracts;
|
||||
|
||||
namespace SmallSoftwareBusinessLogic.Implementations;
|
||||
|
||||
internal class SoftwareBusinessLogicContract(ISoftwareStorageContract
|
||||
softwareStorageContract, ILogger logger) : ISoftwareBusinessLogicContract
|
||||
{
|
||||
private readonly ILogger _logger = logger;
|
||||
private readonly ISoftwareStorageContract _softwareStorageContract =
|
||||
softwareStorageContract;
|
||||
public List<SoftwareDataModel> GetAllSoftwares(bool onlyActive)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
public List<SoftwareDataModel> GetAllSoftwaresByManufacturer(string
|
||||
manufacturerId, bool onlyActive = true)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
public List<SoftwareHistoryDataModel> GetSoftwareHistoryBySoftware(string
|
||||
softwareId)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
public SoftwareDataModel GetSoftwareByData(string data)
|
||||
{
|
||||
return new("", "", SoftwareType.None, "", 0, true);
|
||||
}
|
||||
public void InsertSoftware(SoftwareDataModel softwareDataModel)
|
||||
{
|
||||
}
|
||||
public void UpdateSoftware(SoftwareDataModel softwareDataModel)
|
||||
{
|
||||
}
|
||||
public void DeleteSoftware(string id)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SmallSoftwareContracts.BusinessLogicsContracts;
|
||||
using SmallSoftwareContracts.DataModels;
|
||||
using SmallSoftwareContracts.StoragesContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SmallSoftwareBusinessLogic.Implementations;
|
||||
|
||||
internal class WorkerBusinessLogicContract(IWorkerStorageContract
|
||||
workerStorageContract, ILogger logger) : IWorkerBusinessLogicContract
|
||||
{
|
||||
private readonly ILogger _logger = logger;
|
||||
private readonly IWorkerStorageContract _workerStorageContract =
|
||||
workerStorageContract;
|
||||
public List<WorkerDataModel> GetAllWorkers(bool onlyActive = true)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
public List<WorkerDataModel> GetAllWorkersByPost(string postId, bool
|
||||
onlyActive = true)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
public List<WorkerDataModel> GetAllWorkersByBirthDate(DateTime fromDate,
|
||||
DateTime toDate, bool onlyActive = true)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
public List<WorkerDataModel> GetAllWorkersByEmploymentDate(DateTime
|
||||
fromDate, DateTime toDate, bool onlyActive = true)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
public WorkerDataModel GetWorkerByData(string data)
|
||||
{
|
||||
return new("", "", "", DateTime.Now, DateTime.Now, true);
|
||||
}
|
||||
public void InsertWorker(WorkerDataModel workerDataModel)
|
||||
{
|
||||
}
|
||||
public void UpdateWorker(WorkerDataModel workerDataModel)
|
||||
{
|
||||
}
|
||||
public void DeleteWorker(string id)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SmallSoftwareContracts\SmallSoftwareContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -5,11 +5,10 @@ using SmallSoftwareContracts.Infrastructure;
|
||||
|
||||
namespace SmallSoftwareContracts.DataModels;
|
||||
|
||||
public class PostDataModel(string id, string postId, string postName, PostType
|
||||
public class PostDataModel(string id, string postName, PostType
|
||||
postType, double salary, bool isActual, DateTime changeDate) : IValidation
|
||||
{
|
||||
public string Id { get; private set; } = id;
|
||||
public string PostId { 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;
|
||||
@@ -23,12 +22,6 @@ public class PostDataModel(string id, string postId, string postName, PostType
|
||||
if (!Id.IsGuid())
|
||||
throw new ValidationException("The value in the field Id is not a unique identifier");
|
||||
|
||||
if (PostId.IsEmpty())
|
||||
throw new ValidationException("Field PostId is empty");
|
||||
|
||||
if (!PostId.IsGuid())
|
||||
throw new ValidationException("The value in the field PostId is not a unique identifier");
|
||||
|
||||
if (PostName.IsEmpty())
|
||||
throw new ValidationException("Field PostName is empty");
|
||||
|
||||
|
||||
@@ -7,12 +7,10 @@ using System.Text.RegularExpressions;
|
||||
namespace SmallSoftwareContracts.DataModels;
|
||||
|
||||
|
||||
public class RequestDataModel(string id, string workerId, string email, double sum,
|
||||
bool isCancel, List<InstallationRequestDataModel> softwares) : IValidation
|
||||
public class RequestDataModel(string id, string workerId, string email, double sum, bool isCancel, List<InstallationRequestDataModel> softwares) : IValidation
|
||||
{
|
||||
public string Id { get; private set; } = id;
|
||||
public string WorkerId { get; private set; } = workerId;
|
||||
public DateTime RequestDate { get; private set; } = DateTime.UtcNow;
|
||||
public string Email { get; private set; } = email;
|
||||
public double Sum { get; private set; } = sum;
|
||||
public bool IsCancel { get; private set; } = isCancel;
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.12.35728.132 d17.12
|
||||
VisualStudioVersion = 17.12.35728.132
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SmallSoftwareContracts", "SmallSoftwareContracts\SmallSoftwareContracts.csproj", "{07D2A792-3603-47CB-B5A3-9736E582F496}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SmallSoftwareTests", "SmallSoftwareTests\SmallSoftwareTests.csproj", "{A98AC101-F5F5-4270-97D6-B5FA766D3E64}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SmallSoftwareBusinessLogic", "SmallSoftwareBusinessLogic\SmallSoftwareBusinessLogic.csproj", "{C4E0D33E-8DBB-4BB5-8CCE-D2888F754EC7}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -21,6 +23,10 @@ Global
|
||||
{A98AC101-F5F5-4270-97D6-B5FA766D3E64}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A98AC101-F5F5-4270-97D6-B5FA766D3E64}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A98AC101-F5F5-4270-97D6-B5FA766D3E64}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C4E0D33E-8DBB-4BB5-8CCE-D2888F754EC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C4E0D33E-8DBB-4BB5-8CCE-D2888F754EC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C4E0D33E-8DBB-4BB5-8CCE-D2888F754EC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C4E0D33E-8DBB-4BB5-8CCE-D2888F754EC7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -15,40 +15,18 @@ internal class PostDataModelTests
|
||||
[Test]
|
||||
public void IdIsNullOrEmptyTest()
|
||||
{
|
||||
var post = CreateDataModel(null, Guid.NewGuid().ToString(), "name",
|
||||
var post = CreateDataModel(null, "name",
|
||||
PostType.SoftInstaller, 10, true, DateTime.UtcNow);
|
||||
Assert.That(() => post.Validate(),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
post = CreateDataModel(string.Empty, Guid.NewGuid().ToString(),
|
||||
"name", PostType.SoftInstaller, 10, true, DateTime.UtcNow);
|
||||
post = CreateDataModel(string.Empty, "name", PostType.SoftInstaller, 10, true, DateTime.UtcNow);
|
||||
Assert.That(() => post.Validate(),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
[Test]
|
||||
public void IdIsNotGuidTest()
|
||||
{
|
||||
var post = CreateDataModel("id", Guid.NewGuid().ToString(), "name",
|
||||
PostType.SoftInstaller, 10, true, DateTime.UtcNow);
|
||||
Assert.That(() => post.Validate(),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
[Test]
|
||||
public void PostIdIsNullEmptyTest()
|
||||
{
|
||||
var post = CreateDataModel(Guid.NewGuid().ToString(), null, "name",
|
||||
PostType.SoftInstaller, 10, true, DateTime.UtcNow);
|
||||
Assert.That(() => post.Validate(),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
post = CreateDataModel(Guid.NewGuid().ToString(), string.Empty,
|
||||
"name", PostType.SoftInstaller, 10, true, DateTime.UtcNow);
|
||||
Assert.That(() => post.Validate(),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
[Test]
|
||||
public void PostIdIsNotGuidTest()
|
||||
{
|
||||
var post = CreateDataModel(Guid.NewGuid().ToString(), "postId",
|
||||
"name", PostType.SoftInstaller, 10, true, DateTime.UtcNow);
|
||||
var post = CreateDataModel("id", "name", PostType.SoftInstaller, 10, true, DateTime.UtcNow);
|
||||
Assert.That(() => post.Validate(),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
@@ -56,12 +34,10 @@ internal class PostDataModelTests
|
||||
|
||||
public void PostNameIsEmptyTest()
|
||||
{
|
||||
var manufacturer = CreateDataModel(Guid.NewGuid().ToString(),
|
||||
Guid.NewGuid().ToString(), null, PostType.SoftInstaller, 10, true, DateTime.UtcNow);
|
||||
var manufacturer = CreateDataModel(Guid.NewGuid().ToString(), null, PostType.SoftInstaller, 10, true, DateTime.UtcNow);
|
||||
Assert.That(() => manufacturer.Validate(),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
manufacturer = CreateDataModel(Guid.NewGuid().ToString(),
|
||||
Guid.NewGuid().ToString(), string.Empty, PostType.SoftInstaller, 10, true,
|
||||
manufacturer = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, PostType.SoftInstaller, 10, true,
|
||||
DateTime.UtcNow);
|
||||
Assert.That(() => manufacturer.Validate(),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
@@ -69,8 +45,7 @@ internal class PostDataModelTests
|
||||
[Test]
|
||||
public void PostTypeIsNoneTest()
|
||||
{
|
||||
var post = CreateDataModel(Guid.NewGuid().ToString(),
|
||||
Guid.NewGuid().ToString(), "name", PostType.None, 10, true, DateTime.UtcNow);
|
||||
var post = CreateDataModel(Guid.NewGuid().ToString(), "name", PostType.None, 10, true, DateTime.UtcNow);
|
||||
Assert.That(() => post.Validate(),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
@@ -78,11 +53,10 @@ internal class PostDataModelTests
|
||||
public void SalaryIsLessOrZeroTest()
|
||||
{
|
||||
var post = CreateDataModel(Guid.NewGuid().ToString(),
|
||||
Guid.NewGuid().ToString(), "name", PostType.SoftInstaller, 0, true, DateTime.UtcNow);
|
||||
"name", PostType.SoftInstaller, 0, true, DateTime.UtcNow);
|
||||
Assert.That(() => post.Validate(),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
post = CreateDataModel(Guid.NewGuid().ToString(),
|
||||
Guid.NewGuid().ToString(), "name", PostType.SoftInstaller, -10, true,
|
||||
post = CreateDataModel(Guid.NewGuid().ToString(), "name", PostType.SoftInstaller, -10, true,
|
||||
DateTime.UtcNow);
|
||||
Assert.That(() => post.Validate(),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
@@ -97,13 +71,12 @@ internal class PostDataModelTests
|
||||
var salary = 10;
|
||||
var isActual = false;
|
||||
var changeDate = DateTime.UtcNow.AddDays(-1);
|
||||
var post = CreateDataModel(postId, postPostId, postName, postType,
|
||||
var post = CreateDataModel(postId, postName, postType,
|
||||
salary, isActual, changeDate);
|
||||
Assert.That(() => post.Validate(), Throws.Nothing);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(post.Id, Is.EqualTo(postId));
|
||||
Assert.That(post.PostId, Is.EqualTo(postPostId));
|
||||
Assert.That(post.PostName, Is.EqualTo(postName));
|
||||
Assert.That(post.PostType, Is.EqualTo(postType));
|
||||
Assert.That(post.Salary, Is.EqualTo(salary));
|
||||
@@ -111,8 +84,8 @@ internal class PostDataModelTests
|
||||
Assert.That(post.ChangeDate, Is.EqualTo(changeDate));
|
||||
});
|
||||
}
|
||||
private static PostDataModel CreateDataModel(string? id, string? postId,
|
||||
private static PostDataModel CreateDataModel(string? id,
|
||||
string? postName, PostType postType, double salary, bool isActual, DateTime
|
||||
changeDate) =>
|
||||
new (id, postId, postName, postType, salary, isActual, changeDate);
|
||||
new (id, postName, postType, salary, isActual, changeDate);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user