Заготовки реализаций

This commit is contained in:
2025-03-13 13:23:30 +04:00
parent d29912621f
commit bcde0d8310
11 changed files with 268 additions and 4 deletions

View File

@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>preview</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AndDietCokeProject\AndDietCokeContracts.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,36 @@
using AndDietCokeContracts.BisnessLogicsContracts;
using AndDietCokeContracts.DataModels;
using AndDietCokeContracts.StoragesContracts;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AndDietCokeBuisnessLogic.Implementations;
internal class BuyerBuisnessLogicContract(IBuyerStorageContract buyerStorageContract, ILogger logger) : IBuyerBusinessLogicContract
{
private readonly ILogger _logger = logger;
private readonly IBuyerStorageContract _buyerStorageContract =
buyerStorageContract;
public List<BuyerDataModel> GetAllBuyers()
{
return [];
}
public BuyerDataModel GetBuyerByData(string data)
{
return new("", "", "");
}
public void InsertBuyer(BuyerDataModel buyerDataModel)
{
}
public void UpdateBuyer(BuyerDataModel buyerDataModel)
{
}
public void DeleteBuyer(string id)
{
}
}

View File

@@ -0,0 +1,40 @@
using AndDietCokeContracts.BisnessLogicsContracts;
using AndDietCokeContracts.DataModels;
using AndDietCokeContracts.Enums;
using AndDietCokeContracts.StoragesContracts;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AndDietCokeBuisnessLogic.Implementations;
internal class DishBuisnessLogicContract(IDishStorageContract dishStorageContract, ILogger logger) : IDishBusinessLogicContract
{
private readonly ILogger _logger = logger;
private readonly IDishStorageContract _dishStorageContract = dishStorageContract;
public List<DishDataModel> GetAllDishes(bool onlyActive)
{
return [];
}
public List<DishHistoryDataModel> GetDishHistoryByDish(string dishId)
{
return [];
}
public DishDataModel GetDishByData(string data)
{
return new("", "", DishType.None, 0, true);
}
public void InsertDish(DishDataModel dishDataModel)
{
}
public void UpdateDish(DishDataModel dishDataModel)
{
}
public void DeleteDish(string id)
{
}
}

View File

@@ -0,0 +1,43 @@
using AndDietCokeContracts.BisnessLogicsContracts;
using AndDietCokeContracts.DataModels;
using AndDietCokeContracts.Enums;
using AndDietCokeContracts.StoragesContracts;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AndDietCokeBuisnessLogic.Implementations;
internal class PostBuisnessLogicContract(IPostStorageContract postStorageContract, ILogger logger) : IPostBusinessLogicContract
{
private readonly ILogger _logger = logger;
private readonly IPostStorageContract _postStorageContract =
postStorageContract;
public List<PostDataModel> GetAllPosts()
{
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)
{
}
}

View File

@@ -0,0 +1,31 @@
using AndDietCokeContracts.BisnessLogicsContracts;
using AndDietCokeContracts.DataModels;
using AndDietCokeContracts.StoragesContracts;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AndDietCokeBuisnessLogic.Implementations;
internal class SalaryBusinessLogicContract(ISalaryStorageContract salaryStorageContract, ISaleStorageContract saleStorageContract, IPostStorageContract postStorageContract, IWorkerStorageContract workerStorageContract, ILogger logger) : ISalaryBusinessLogicContract
{
private readonly ILogger _logger = logger;
private readonly ISalaryStorageContract _salaryStorageContract = salaryStorageContract;
private readonly ISaleStorageContract _saleStorageContract = saleStorageContract;
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 CalculateSalaryByMounth(DateTime date)
{
}
}

View File

@@ -0,0 +1,43 @@
using AndDietCokeContracts.BisnessLogicsContracts;
using AndDietCokeContracts.DataModels;
using AndDietCokeContracts.StoragesContracts;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AndDietCokeBuisnessLogic.Implementations;
internal class SaleBusinessLogicContract(ISaleStorageContract saleStorageContract, ILogger logger) : ISaleBusinessLogicContract
{
private readonly ILogger _logger = logger;
private readonly ISaleStorageContract _saleStorageContract = saleStorageContract;
public List<SaleDataModel> GetAllSalesByPeriod(DateTime fromDate, DateTime toDate)
{
return [];
}
public List<SaleDataModel> GetAllSalesByWorkerByPeriod(string workerId, DateTime fromDate, DateTime toDate)
{
return [];
}
public List<SaleDataModel> GetAllSalesByBuyerByPeriod(string? buyerId, DateTime fromDate, DateTime toDate)
{
return [];
}
public List<SaleDataModel> GetAllSalesByDishByPeriod(string productId, DateTime fromDate, DateTime toDate)
{
return [];
}
public SaleDataModel GetSaleByData(string data)
{
return new("", "", "", 0, true, false, []);
}
public void InsertSale(SaleDataModel saleDataModel)
{
}
public void CancelSale(string id)
{
}
}

View File

@@ -0,0 +1,47 @@
using AndDietCokeContracts.BisnessLogicsContracts;
using AndDietCokeContracts.DataModels;
using AndDietCokeContracts.StoragesContracts;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AndDietCokeBuisnessLogic.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)
{
}
}

View File

@@ -5,7 +5,9 @@ VisualStudioVersion = 17.7.34024.191
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AndDietCokeContracts", "AndDietCokeProject\AndDietCokeContracts.csproj", "{624595D1-D7AA-4448-AA30-4D5AA21AE6D6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AndDietCokeTests", "AndDietCokeTests\AndDietCokeTests.csproj", "{EABA3AD5-7690-448A-BEE6-010499DD8790}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AndDietCokeTests", "AndDietCokeTests\AndDietCokeTests.csproj", "{EABA3AD5-7690-448A-BEE6-010499DD8790}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AndDietCokeBuisnessLogic", "AndDietCokeBuisnessLogic\AndDietCokeBuisnessLogic.csproj", "{3C1C0E8F-5CB4-4E93-B20C-86FF4B248ECF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -21,6 +23,10 @@ Global
{EABA3AD5-7690-448A-BEE6-010499DD8790}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EABA3AD5-7690-448A-BEE6-010499DD8790}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EABA3AD5-7690-448A-BEE6-010499DD8790}.Release|Any CPU.Build.0 = Release|Any CPU
{3C1C0E8F-5CB4-4E93-B20C-86FF4B248ECF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3C1C0E8F-5CB4-4E93-B20C-86FF4B248ECF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C1C0E8F-5CB4-4E93-B20C-86FF4B248ECF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C1C0E8F-5CB4-4E93-B20C-86FF4B248ECF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -18,6 +18,7 @@ postType, double salary, bool isActual, DateTime changeDate) : IValidation
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()
{

View File

@@ -6,7 +6,7 @@ using System.Text;
using System.Threading.Tasks;
namespace AndDietCokeContracts.StoragesContracts;
public interface IProductStorageContract
public interface IDishStorageContract
{
List<DishDataModel> GetList(bool onlyActive = true);
List<DishHistoryDataModel> GetHistoryByDishId(string dishId);

View File

@@ -16,7 +16,7 @@ internal class PostDataModelTests
[Test]
public void IdIsNullOrEmptyTest()
{
var post = CreateDataModel(null, Guid.NewGuid().ToString(), "name", PostType.Waiter, 10, true, DateTime.UtcNow);
var post = CreateDataModel("0", Guid.NewGuid().ToString(), "name", PostType.Waiter, 10, true, DateTime.UtcNow);
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
post = CreateDataModel(string.Empty, Guid.NewGuid().ToString(), "name", PostType.Waiter, 10, true, DateTime.UtcNow);
Assert.That(() => post.Validate(), Throws.TypeOf<ValidationException>());
@@ -81,7 +81,6 @@ internal class PostDataModelTests
Assert.That(post.PostName, Is.EqualTo(postName));
Assert.That(post.PostType, Is.EqualTo(postType));
Assert.That(post.Salary, Is.EqualTo(salary));
Assert.That(post.ChangeDate, Is.EqualTo(changeDate));
});
}
private static PostDataModel CreateDataModel(string? id, string? postId, string? postName, PostType postType, double salary, bool isActual, DateTime changeDate) => new(id, postId, postName, postType, salary, isActual, changeDate);