лвб 3 начал
This commit is contained in:
parent
96234cb606
commit
4bcc573fbb
14
WinForms/OrderBusinessLogic/OrderBusinessLogic.csproj
Normal file
14
WinForms/OrderBusinessLogic/OrderBusinessLogic.csproj
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\OrdersContracts\OrdersContracts.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
67
WinForms/OrderBusinessLogic/OrderLogic.cs
Normal file
67
WinForms/OrderBusinessLogic/OrderLogic.cs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
using OrdersContracts.BindingModels;
|
||||||
|
using OrdersContracts.BusinessLogicContracts;
|
||||||
|
using OrdersContracts.StorageContracts;
|
||||||
|
using OrdersContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OrderBusinessLogic
|
||||||
|
{
|
||||||
|
public class OrderLogic : IOrderLogic
|
||||||
|
{
|
||||||
|
private readonly IOrderStorage _orderStorage;
|
||||||
|
public OrderLogic(IOrderStorage orderStorage)
|
||||||
|
{
|
||||||
|
_orderStorage = orderStorage;
|
||||||
|
}
|
||||||
|
public void CreateOrUpdate(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
var element = _orderStorage.GetElement(
|
||||||
|
new OrderBindingModel
|
||||||
|
{
|
||||||
|
Info = model.Info,
|
||||||
|
Name = model.Name,
|
||||||
|
Status = model.Status,
|
||||||
|
Amount = model.Amount
|
||||||
|
});
|
||||||
|
if (element != null && element.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new Exception("Такой заказ уже существует");
|
||||||
|
}
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
_orderStorage.Update(model);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_orderStorage.Insert(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Delete(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
var element = _orderStorage.GetElement(new OrderBindingModel { Id = model.Id });
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Заказ не найден");
|
||||||
|
}
|
||||||
|
_orderStorage.Delete(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<OrderViewModel> Read(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return _orderStorage.GetFullList();
|
||||||
|
}
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return new List<OrderViewModel> { _orderStorage.GetElement(model) };
|
||||||
|
}
|
||||||
|
return _orderStorage.GetFilteredList(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
WinForms/OrderBusinessLogic/StatusLogic.cs
Normal file
60
WinForms/OrderBusinessLogic/StatusLogic.cs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
using OrdersContracts.BindingModels;
|
||||||
|
using OrdersContracts.BusinessLogicContracts;
|
||||||
|
using OrdersContracts.StorageContracts;
|
||||||
|
using OrdersContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace OrderBusinessLogic
|
||||||
|
{
|
||||||
|
public class StatusLogic : IStatusLogic
|
||||||
|
{
|
||||||
|
private readonly IStatusStorage _statusStorage;
|
||||||
|
public StatusLogic(IStatusStorage statusStorage)
|
||||||
|
{
|
||||||
|
_statusStorage = statusStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateOrUpdate(StatusBindingModel model)
|
||||||
|
{
|
||||||
|
var element = _statusStorage.GetElement(
|
||||||
|
new StatusBindingModel
|
||||||
|
{
|
||||||
|
Name = model.Name
|
||||||
|
});
|
||||||
|
if (element != null && element.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new Exception("Такой статус уже существует");
|
||||||
|
}
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
_statusStorage.Update(model);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_statusStorage.Insert(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Delete(StatusBindingModel model)
|
||||||
|
{
|
||||||
|
var element = _statusStorage.GetElement(new StatusBindingModel { Id = model.Id });
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Статус не найден");
|
||||||
|
}
|
||||||
|
_statusStorage.Delete(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<StatusViewModel> Read(StatusBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return _statusStorage.GetFullList();
|
||||||
|
}
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return new List<StatusViewModel> { _statusStorage.GetElement(model) };
|
||||||
|
}
|
||||||
|
return _statusStorage.GetFilteredList(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
17
WinForms/OrdersContracts/BindingModels/OrderBindingModel.cs
Normal file
17
WinForms/OrdersContracts/BindingModels/OrderBindingModel.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OrdersContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class OrderBindingModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Info { get; set; }
|
||||||
|
public string Status { get; set; }
|
||||||
|
public int? Amount { get; set; }
|
||||||
|
}
|
||||||
|
}
|
15
WinForms/OrdersContracts/BindingModels/StatusBindingModel.cs
Normal file
15
WinForms/OrdersContracts/BindingModels/StatusBindingModel.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OrdersContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class StatusBindingModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
using OrdersContracts.BindingModels;
|
||||||
|
using OrdersContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OrdersContracts.BusinessLogicContracts
|
||||||
|
{
|
||||||
|
public interface IOrderLogic
|
||||||
|
{
|
||||||
|
List<OrderViewModel> Read(OrderBindingModel model);
|
||||||
|
void CreateOrUpdate(OrderBindingModel model);
|
||||||
|
void Delete(OrderBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
using OrdersContracts.BindingModels;
|
||||||
|
using OrdersContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OrdersContracts.BusinessLogicContracts
|
||||||
|
{
|
||||||
|
public interface IStatusLogic
|
||||||
|
{
|
||||||
|
List<StatusViewModel> Read(StatusBindingModel model);
|
||||||
|
void CreateOrUpdate(StatusBindingModel model);
|
||||||
|
void Delete(StatusBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
10
WinForms/OrdersContracts/OrdersContracts.csproj
Normal file
10
WinForms/OrdersContracts/OrdersContracts.csproj
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
20
WinForms/OrdersContracts/StorageContracts/IOrderStorage.cs
Normal file
20
WinForms/OrdersContracts/StorageContracts/IOrderStorage.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using OrdersContracts.BindingModels;
|
||||||
|
using OrdersContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OrdersContracts.StorageContracts
|
||||||
|
{
|
||||||
|
public interface IOrderStorage
|
||||||
|
{
|
||||||
|
List<OrderViewModel> GetFullList();
|
||||||
|
List<OrderViewModel> GetFilteredList(OrderBindingModel model);
|
||||||
|
OrderViewModel GetElement(OrderBindingModel model);
|
||||||
|
void Insert(OrderBindingModel model);
|
||||||
|
void Update(OrderBindingModel model);
|
||||||
|
void Delete(OrderBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
21
WinForms/OrdersContracts/StorageContracts/IStatusStorage.cs
Normal file
21
WinForms/OrdersContracts/StorageContracts/IStatusStorage.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using OrdersContracts.BindingModels;
|
||||||
|
using OrdersContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OrdersContracts.StorageContracts
|
||||||
|
{
|
||||||
|
public interface IStatusStorage
|
||||||
|
{
|
||||||
|
List<StatusViewModel> GetFullList();
|
||||||
|
List<StatusViewModel> GetFilteredList(StatusBindingModel model);
|
||||||
|
StatusViewModel GetElement(StatusBindingModel model);
|
||||||
|
|
||||||
|
void Insert(StatusBindingModel model);
|
||||||
|
void Update(StatusBindingModel model);
|
||||||
|
void Delete(StatusBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
24
WinForms/OrdersContracts/ViewModels/OrderViewModel.cs
Normal file
24
WinForms/OrdersContracts/ViewModels/OrderViewModel.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OrdersContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class OrderViewModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("ФИО")]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("Описание")]
|
||||||
|
public string Info { get; set; }
|
||||||
|
[DisplayName("Статус")]
|
||||||
|
public string Status { get; set; }
|
||||||
|
[DisplayName("Сумма заказа")]
|
||||||
|
public string Amount { get; set; }
|
||||||
|
}
|
||||||
|
}
|
14
WinForms/OrdersContracts/ViewModels/StatusViewModel.cs
Normal file
14
WinForms/OrdersContracts/ViewModels/StatusViewModel.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OrdersContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class StatusViewModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
21
WinForms/VisualComponentsLib/IStatusStorage.cs
Normal file
21
WinForms/VisualComponentsLib/IStatusStorage.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using OrdersContracts.BindingModels;
|
||||||
|
using OrdersContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OrdersContracts.StorageContracts
|
||||||
|
{
|
||||||
|
public interface IStatusStorage
|
||||||
|
{
|
||||||
|
List<StatusViewModel> GetFullList();
|
||||||
|
List<StatusViewModel> GetFilteredList(StatusBindingModel model);
|
||||||
|
StatusViewModel GetElement(StatusBindingModel model);
|
||||||
|
|
||||||
|
void Insert(StatusBindingModel model);
|
||||||
|
void Update(StatusBindingModel model);
|
||||||
|
void Delete(StatusBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,11 @@ VisualStudioVersion = 17.3.32901.215
|
|||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinForms", "WinForms\WinForms.csproj", "{10D1B0BE-6B52-41E6-8B57-4AFC49A26F17}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinForms", "WinForms\WinForms.csproj", "{10D1B0BE-6B52-41E6-8B57-4AFC49A26F17}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisualComponentsLib", "VisualComponentsLib\VisualComponentsLib.csproj", "{EF8D5392-CB3C-429E-BB8F-A7353F56E1D8}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VisualComponentsLib", "VisualComponentsLib\VisualComponentsLib.csproj", "{EF8D5392-CB3C-429E-BB8F-A7353F56E1D8}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrdersContracts", "OrdersContracts\OrdersContracts.csproj", "{82FC5A5D-EA93-49E2-BC93-8AE514148FA0}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrderBusinessLogic", "OrderBusinessLogic\OrderBusinessLogic.csproj", "{071BD445-8513-4B12-A60C-2531F2B795F5}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -21,6 +25,14 @@ Global
|
|||||||
{EF8D5392-CB3C-429E-BB8F-A7353F56E1D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{EF8D5392-CB3C-429E-BB8F-A7353F56E1D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{EF8D5392-CB3C-429E-BB8F-A7353F56E1D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{EF8D5392-CB3C-429E-BB8F-A7353F56E1D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{EF8D5392-CB3C-429E-BB8F-A7353F56E1D8}.Release|Any CPU.Build.0 = Release|Any CPU
|
{EF8D5392-CB3C-429E-BB8F-A7353F56E1D8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{82FC5A5D-EA93-49E2-BC93-8AE514148FA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{82FC5A5D-EA93-49E2-BC93-8AE514148FA0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{82FC5A5D-EA93-49E2-BC93-8AE514148FA0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{82FC5A5D-EA93-49E2-BC93-8AE514148FA0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{071BD445-8513-4B12-A60C-2531F2B795F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{071BD445-8513-4B12-A60C-2531F2B795F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{071BD445-8513-4B12-A60C-2531F2B795F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{071BD445-8513-4B12-A60C-2531F2B795F5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user