Contracts

This commit is contained in:
ShabOl 2024-02-06 23:43:23 +04:00
parent fb5a98c8ed
commit dfbe5539dd
21 changed files with 259 additions and 10 deletions

View File

@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoWorkshop", "AutoWorksho
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoWorkshopDataModels", "AutoWorkshopDataModels\AutoWorkshopDataModels.csproj", "{D52094D2-A57E-4BAD-B049-3B64065463DA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoWorkshopContracts", "AutoWorkshopContracts\AutoWorkshopContracts.csproj", "{93CF1C25-57B5-4E95-A394-E01AE440E138}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -21,6 +23,10 @@ Global
{D52094D2-A57E-4BAD-B049-3B64065463DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D52094D2-A57E-4BAD-B049-3B64065463DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D52094D2-A57E-4BAD-B049-3B64065463DA}.Release|Any CPU.Build.0 = Release|Any CPU
{93CF1C25-57B5-4E95-A394-E01AE440E138}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{93CF1C25-57B5-4E95-A394-E01AE440E138}.Debug|Any CPU.Build.0 = Debug|Any CPU
{93CF1C25-57B5-4E95-A394-E01AE440E138}.Release|Any CPU.ActiveCfg = Release|Any CPU
{93CF1C25-57B5-4E95-A394-E01AE440E138}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\AutoWorkshopDataModels\AutoWorkshopDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,11 @@
using AutoWorkshopDataModels.Models;
namespace AutoWorkshopContracts.BindingModels
{
public class ComponentBindingModel : IComponentModel
{
public int Id { get; set; }
public string ComponentName { get; set; } = string.Empty;
public double Cost { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using AutoWorkshopDataModels.Models;
using AutoWorkshopDataModels.Enums;
namespace AutoWorkshopContracts.BindingModels
{
public class OrderBindingModel : IOrderModel
{
public int Id { get; set; }
public int ProductId { get; set; }
public int Count { get; set; }
public double Sum { get; set; }
public OrderStatus Status { get; set; } = OrderStatus.Undefined;
public DateTime DateCreate { get; set; } = DateTime.Now;
public DateTime? DateImplement { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using AutoWorkshopDataModels.Models;
namespace AutoWorkshopContracts.BindingModels
{
public class RepairBindingModel : IRepairModel
{
public int Id { get; set; }
public string RepairName { get; set; } = string.Empty;
public double Price { get; set; }
public Dictionary<int, (IComponentModel, int)> RepairComponents
{
get;
set;
} = new();
}
}

View File

@ -0,0 +1,16 @@
using AutoWorkshopContracts.BindingModels;
using AutoWorkshopContracts.SearchModels;
using AutoWorkshopContracts.ViewModels;
namespace AutoWorkshopContracts.BusinessLogicContracts
{
public interface IComponentLogic
{
List<ComponentViewModel>? ReadList(ComponentSearchModel? model);
ComponentViewModel? ReadElement(ComponentSearchModel model);
bool Create(ComponentBindingModel model);
bool Update(ComponentBindingModel model);
bool Delete(ComponentBindingModel model);
}
}

View File

@ -0,0 +1,15 @@
using AutoWorkshopContracts.BindingModels;
using AutoWorkshopContracts.SearchModels;
using AutoWorkshopContracts.ViewModels;
namespace AutoWorkshopContracts.BusinessLogicContracts
{
public interface IOrderLogic
{
List<OrderViewModel>? ReadList(OrderSearchModel? model);
bool CreateOrder(OrderBindingModel model);
bool TakeOrderInWork(OrderBindingModel model);
bool FinishOrder(OrderBindingModel model);
bool DeliveryOrder(OrderBindingModel model);
}
}

View File

@ -0,0 +1,15 @@
using AutoWorkshopContracts.BindingModels;
using AutoWorkshopContracts.SearchModels;
using AutoWorkshopContracts.ViewModels;
namespace AutoWorkshopContracts.BusinessLogicContracts
{
public interface IRepairLogic
{
List<RepairViewModel>? ReadList(RepairSearchModel? model);
RepairViewModel? ReadElement(RepairSearchModel model);
bool Create(RepairBindingModel model);
bool Update(RepairBindingModel model);
bool Delete(RepairBindingModel model);
}
}

View File

@ -0,0 +1,8 @@
namespace AutoWorkshopContracts.SearchModels
{
public class ComponentSearchModel
{
public int? Id { get; set; }
public string? ComponentName { get; set; }
}
}

View File

@ -0,0 +1,7 @@
namespace AutoWorkshopContracts.SearchModels
{
public class OrderSearchModel
{
public int? Id { get; set; }
}
}

View File

@ -0,0 +1,8 @@
namespace AutoWorkshopContracts.SearchModels
{
public class RepairSearchModel
{
public int? Id { get; set; }
public string? RepairName { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using AutoWorkshopContracts.BindingModels;
using AutoWorkshopContracts.SearchModels;
using AutoWorkshopContracts.ViewModels;
namespace AutoWorkshopContracts.StoragesContracts
{
public interface IComponentStorage
{
List<ComponentViewModel> GetFullList();
List<ComponentViewModel> GetFilteredList(ComponentSearchModel model);
ComponentViewModel? GetElement(ComponentSearchModel model);
ComponentViewModel? Insert(ComponentBindingModel model);
ComponentViewModel? Update(ComponentBindingModel model);
ComponentViewModel? Delete(ComponentBindingModel model);
}
}

View File

@ -0,0 +1,16 @@
using AutoWorkshopContracts.BindingModels;
using AutoWorkshopContracts.SearchModels;
using AutoWorkshopContracts.ViewModels;
namespace AutoWorkshopContracts.StoragesContracts
{
public interface IOrderStorage
{
List<OrderViewModel> GetFullList();
List<OrderViewModel> GetFilteredList(OrderSearchModel model);
OrderViewModel? GetElement(OrderSearchModel model);
OrderViewModel? Insert(OrderBindingModel model);
OrderViewModel? Update(OrderBindingModel model);
OrderViewModel? Delete(OrderBindingModel model);
}
}

View File

@ -0,0 +1,15 @@
using AutoWorkshopContracts.SearchModels;
using AutoWorkshopContracts.ViewModels;
namespace AutoWorkshopContracts.StoragesContracts
{
public interface IProductStorage
{
List<RepairViewModel> GetFullList();
List<RepairViewModel> GetFilteredList(RepairSearchModel model);
RepairViewModel? GetElement(RepairSearchModel model);
RepairViewModel? Insert(RepairSearchModel model);
RepairViewModel? Update(RepairSearchModel model);
RepairViewModel? Delete(RepairSearchModel model);
}
}

View File

@ -0,0 +1,16 @@
using AutoWorkshopDataModels.Models;
using System.ComponentModel;
namespace AutoWorkshopContracts.ViewModels
{
public class ComponentViewModel : IComponentModel
{
public int Id { get; set; }
[DisplayName("Название компонента")]
public string ComponentName { get; set; } = string.Empty;
[DisplayName("Цена")]
public double Cost { get; set; }
}
}

View File

@ -0,0 +1,32 @@
using AutoWorkshopDataModels.Enums;
using AutoWorkshopDataModels.Models;
using System.ComponentModel;
namespace AutoWorkshopContracts.ViewModels
{
public class OrderViewModel : IOrderModel
{
[DisplayName("Номер")]
public int Id { get; set; }
public int ProductId { get; set; }
[DisplayName("Изделие")]
public string ProductName { get; set; } = string.Empty;
[DisplayName("Количество")]
public int Count { get; set; }
[DisplayName("Сумма")]
public double Sum { get; set; }
[DisplayName("Статус")]
public OrderStatus Status { get; set; } = OrderStatus.Undefined;
[DisplayName("Дата создания")]
public DateTime DateCreate { get; set; } = DateTime.Now;
[DisplayName("Дата выполнения")]
public DateTime? DateImplement { get; set; }
}
}

View File

@ -0,0 +1,22 @@
using AutoWorkshopDataModels.Models;
using System.ComponentModel;
namespace AutoWorkshopContracts.ViewModels
{
public class RepairViewModel : IRepairModel
{
public int Id { get; set; }
[DisplayName("Название изделия")]
public string RepairName { get; set; } = string.Empty;
[DisplayName("Цена")]
public double Price { get; set; }
public Dictionary<int, (IComponentModel, int)> RepairComponents
{
get;
set;
} = new();
}
}

View File

@ -1,9 +0,0 @@
namespace AutoWorkshopDataModels
{
public interface IProductModel : IId
{
string ProductName { get; }
double Price { get; }
Dictionary<int, (IComponentModel, int)> ProductComponents { get; }
}
}

View File

@ -1,4 +1,4 @@
namespace AutoWorkshopDataModels
namespace AutoWorkshopDataModels.Models
{
public interface IComponentModel : IId
{

View File

@ -0,0 +1,9 @@
namespace AutoWorkshopDataModels.Models
{
public interface IRepairModel : IId
{
string RepairName { get; }
double Price { get; }
Dictionary<int, (IComponentModel, int)> RepairComponents { get; }
}
}