Steps including creation of Singleton are done.

This commit is contained in:
Yuee Shiness 2023-01-29 23:17:04 +04:00
parent c667c4b626
commit 8f9d84bca0
32 changed files with 1060 additions and 0 deletions

View File

@ -0,0 +1,127 @@
using DressAtelierContracts.BindingModels;
using DressAtelierContracts.BusinessLogicContracts;
using DressAtelierContracts.SearchModels;
using DressAtelierContracts.StorageContracts;
using DressAtelierContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DressAtelierBusinessLogic.BusinessLogic
{
public class DressLogic : IDressLogic
{
private readonly ILogger _logger;
private readonly IDressStorage _productStorage;
public DressLogic(ILogger<DressLogic> logger, IDressStorage productStorage)
{
_logger = logger;
_productStorage = productStorage;
}
public bool Create(DressBindingModel model)
{
CheckModel(model);
if(_productStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(DressBindingModel model)
{
CheckModel(model);
if (_productStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(DressBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. ID:{ID}", model.ID);
if (_productStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public DressViewModel? ReadElement(DressSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. ProductName:{ProductName}.ID:{ ID}", model.ProductName, model.ID);
var element = _productStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. ID:{ID}", element.ID);
return element;
}
public List<DressViewModel>? ReadList(DressSearchModel? model)
{
_logger.LogInformation("ReadList. ProductName:{ProductName}. ID:{ ID}", model?.ProductName, model?.ID);
var list = model == null ? _productStorage.GetFullList() : _productStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
private void CheckModel(DressBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.ProductName))
{
throw new ArgumentNullException("Invalid name of product",nameof(model.ProductName));
}
if (model.Price <= 0)
{
throw new ArgumentNullException("Price of product should be higher than 0", nameof(model.Price));
}
_logger.LogInformation("Product. ProductName:{ProductName}. Cost:{Cost}. ID: {ID}", model.ProductName, model.Price, model.ID);
var element = _productStorage.GetElement(new DressSearchModel
{
ProductName = model.ProductName,
});
if (element != null && element.ID != model.ID)
{
throw new InvalidOperationException("Product with such name already exists");
}
}
}
}

View File

@ -0,0 +1,131 @@
using DressAtelierContracts.BindingModels;
using DressAtelierContracts.BusinessLogicContracts;
using DressAtelierContracts.SearchModels;
using DressAtelierContracts.StorageContracts;
using DressAtelierContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DressAtelierBusinessLogic.BusinessLogic
{
public class MaterialComponentsLogic : IMaterialLogic
{
private readonly ILogger _logger;
private readonly IMaterialStorage _componentStorage;
public MaterialComponentsLogic(ILogger<MaterialComponentsLogic> logger, IMaterialStorage componentStorage)
{
_logger = logger;
_componentStorage = componentStorage;
}
public bool Create(MaterialBindingModel model)
{
CheckModel(model);
if (_componentStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(MaterialBindingModel model)
{
CheckModel(model);
if (_componentStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(MaterialBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. ID:{ID}", model.ID);
if (_componentStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public MaterialViewModel? ReadElement(MaterialSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. ComponentName:{ComponentName}.ID:{ ID}", model.ComponentName, model.ID);
var element = _componentStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. ID:{ID}", element.ID);
return element;
}
public List<MaterialViewModel>? ReadList(MaterialSearchModel? model)
{
_logger.LogInformation("ReadList. ComponentName:{ComponentName}. ID:{ ID}", model?.ComponentName, model?.ID);
var list = model == null ? _componentStorage.GetFullList() : _componentStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
private void CheckModel(MaterialBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.ComponentName))
{
throw new ArgumentNullException("Invalid name of component", nameof(model.ComponentName));
}
if (model.Cost <= 0)
{
throw new ArgumentNullException("Price of component should be higher than 0", nameof(model.Cost));
}
_logger.LogInformation("Component. ComponentName:{ComponentName}. Cost:{ Cost}. ID: { ID} ", model.ComponentName, model.Cost, model.ID);
var element = _componentStorage.GetElement(new MaterialSearchModel
{
ComponentName = model.ComponentName
});
if (element != null && element.ID != model.ID)
{
throw new InvalidOperationException("Component with such name already exists.");
}
}
}
}

View File

@ -0,0 +1,122 @@
using DressAtelierContracts.BindingModels;
using DressAtelierContracts.BusinessLogicContracts;
using DressAtelierContracts.SearchModels;
using DressAtelierContracts.StorageContracts;
using DressAtelierContracts.ViewModels;
using DressAtelierDataModels.Enums;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DressAtelierBusinessLogic.BusinessLogic
{
public class OrderLogic : IOrderLogic
{
private readonly ILogger _logger;
private readonly IOrderStorage _orderStorage;
public OrderLogic(ILogger logger, IOrderStorage orderStorage)
{
_logger = logger;
_orderStorage = orderStorage;
}
public bool CreateOrder(OrderBindingModel model)
{
CheckModel(model);
if (model.Status != OrderStatus.Unknown)
{
_logger.LogWarning("Insert operation failed");
return false;
}
model.Status = OrderStatus.Accepted;
if (_orderStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool GivenOrder(OrderBindingModel model)
{
CheckModel(model);
_logger.LogInformation("Update to given status. ID:{ID}", model.ID);
if (_orderStorage.Update(model) == null || model.Status == OrderStatus.Ready)
{
_logger.LogWarning("Update operation failed");
return false;
}
model.Status = OrderStatus.Given;
return true;
}
public bool ReadyOrder(OrderBindingModel model)
{
CheckModel(model);
_logger.LogInformation("Update to ready status. ID:{ID}", model.ID);
if (_orderStorage.Update(model) == null || model.Status == OrderStatus.InProcess)
{
_logger.LogWarning("Update operation failed");
return false;
}
model.Status = OrderStatus.Ready;
model.DateImplement = DateTime.Now;
return true;
}
public bool TakeOrderInWork(OrderBindingModel model)
{
CheckModel(model);
_logger.LogInformation("Update to ready status. ID:{ID}", model.ID);
if (_orderStorage.Update(model) == null || model.Status == OrderStatus.Accepted)
{
_logger.LogWarning("Update operation failed");
return false;
}
model.Status = OrderStatus.InProcess;
return true;
}
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
{
_logger.LogInformation("ReadList. OrderID:{ID}",model.ID);
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public void CheckModel(OrderBindingModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("Order. OrderID: { ID} ",model.ID);
var element = _orderStorage.GetElement(new OrderSearchModel
{
ID = model.ID
});
if (element == null)
{
throw new InvalidOperationException("Order with such name already exists.");
}
}
}
}

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DressAtelierContracts\DressAtelierContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,20 @@
using DressAtelierDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DressAtelierContracts.BindingModels
{
public class DressBindingModel : IDressModel
{
public int ID { get; set; }
public string ProductName { get; set; } = string.Empty;
public double Price { get; set; }
public Dictionary<int, (IMaterialModel, int)> ProductComponents { get; set; } = new();
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DressAtelierDataModels.Models;
namespace DressAtelierContracts.BindingModels
{
public class MaterialBindingModel : IMaterialModel
{
public int ID { get; set; }
public string ComponentName { get; set; } = string.Empty;
public double Cost { get; set; }
}
}

View File

@ -0,0 +1,27 @@
using DressAtelierDataModels.Enums;
using DressAtelierDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DressAtelierContracts.BindingModels
{
public class OrderBindingModel : IOrderModel
{
public int ProductID { get; set; }
public int Count { get; set; }
public double Sum { get; set; }
public OrderStatus Status { get; set; } = OrderStatus.Unknown;
public DateTime DateCreate { get; set; } = DateTime.Now;
public DateTime? DateImplement { get; set; }
public int ID { get; set; }
}
}

View File

@ -0,0 +1,21 @@
using DressAtelierContracts.BindingModels;
using DressAtelierContracts.SearchModels;
using DressAtelierContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DressAtelierContracts.BusinessLogicContracts
{
public interface IDressLogic
{
List<DressViewModel>? ReadList(DressSearchModel? model);
DressViewModel? ReadElement(DressSearchModel model);
bool Create(DressBindingModel model);
bool Update(DressBindingModel model);
bool Delete(DressBindingModel model);
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DressAtelierContracts.BindingModels;
using DressAtelierContracts.SearchModels;
using DressAtelierContracts.ViewModels;
namespace DressAtelierContracts.BusinessLogicContracts
{
public interface IMaterialLogic
{
List<MaterialViewModel>? ReadList(MaterialSearchModel? model);
MaterialViewModel? ReadElement(MaterialSearchModel model);
bool Create(MaterialBindingModel model);
bool Update(MaterialBindingModel model);
bool Delete(MaterialBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using DressAtelierContracts.BindingModels;
using DressAtelierContracts.SearchModels;
using DressAtelierContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DressAtelierContracts.BusinessLogicContracts
{
public interface IOrderLogic
{
List<OrderViewModel>? ReadList(OrderSearchModel? model);
bool CreateOrder(OrderBindingModel model);
bool TakeOrderInWork(OrderBindingModel model);
bool ReadyOrder(OrderBindingModel model);
bool GivenOrder(OrderBindingModel model);
}
}

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="..\DressAtelierDataModels\DressAtelierDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DressAtelierContracts.SearchModels
{
public class DressSearchModel
{
public int? ID { get; set; }
public string? ProductName { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DressAtelierContracts.SearchModels
{
public class MaterialSearchModel
{
public int? ID { get; set; }
public string? ComponentName { get; set; }
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DressAtelierContracts.SearchModels
{
public class OrderSearchModel
{
public int? ID { get; set; }
}
}

View File

@ -0,0 +1,21 @@
using DressAtelierContracts.BindingModels;
using DressAtelierContracts.SearchModels;
using DressAtelierContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DressAtelierContracts.StorageContracts
{
public interface IDressStorage
{
List<DressViewModel> GetFullList();
List<DressViewModel> GetFilteredList(DressSearchModel model);
DressViewModel? GetElement(DressSearchModel model);
DressViewModel? Insert(DressBindingModel model);
DressViewModel? Delete(DressBindingModel model);
DressViewModel? Update(DressBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using DressAtelierContracts.ViewModels;
using DressAtelierContracts.BindingModels;
using DressAtelierContracts.SearchModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DressAtelierContracts.StorageContracts
{
public interface IMaterialStorage
{
List<MaterialViewModel> GetFullList();
List<MaterialViewModel> GetFilteredList(MaterialSearchModel model);
MaterialViewModel? GetElement(MaterialSearchModel model);
MaterialViewModel? Insert(MaterialBindingModel model);
MaterialViewModel? Update(MaterialBindingModel model);
MaterialViewModel? Delete(MaterialBindingModel model);
}
}

View File

@ -0,0 +1,22 @@
using DressAtelierContracts.BindingModels;
using DressAtelierContracts.SearchModels;
using DressAtelierContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DressAtelierContracts.StorageContracts
{
public interface IOrderStorage
{
List<OrderViewModel>? GetFullList();
List<OrderViewModel> GetFilteredList(OrderSearchModel model);
OrderViewModel? GetElement(OrderSearchModel model);
OrderViewModel? Insert(OrderBindingModel model);
OrderViewModel? Delete(OrderBindingModel model);
OrderViewModel? Update(OrderBindingModel model);
}
}

View File

@ -0,0 +1,23 @@
using DressAtelierDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DressAtelierContracts.ViewModels
{
public class DressViewModel : IDressModel
{
[DisplayName("Name of product")]
public string ProductName { get; set; } = string.Empty;
[DisplayName("Cost")]
public double Price { get; set; }
public Dictionary<int, (IMaterialModel, int)> ProductComponents { get; set; } = new();
public int ID { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using DressAtelierDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
namespace DressAtelierContracts.ViewModels
{
public class MaterialViewModel : IMaterialModel
{
[DisplayName("Name of component")]
public string ComponentName { get; set; } = string.Empty;
[DisplayName("Cost")]
public double Cost { get; set; }
public int ID { get; set; }
}
}

View File

@ -0,0 +1,34 @@
using DressAtelierDataModels.Enums;
using DressAtelierDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DressAtelierContracts.ViewModels
{
public class OrderViewModel : IOrderModel
{
public int ProductID { get; set; }
[DisplayName("Quantity")]
public int Count { get; set; }
[DisplayName("Overall price")]
public double Sum { get; set; }
[DisplayName("Status")]
public OrderStatus Status { get; set; } = OrderStatus.Unknown;
[DisplayName("Date of creation")]
public DateTime DateCreate { get; set; } = DateTime.Now;
[DisplayName("Date of implementation")]
public DateTime? DateImplement { get; set; }
[DisplayName("ID")]
public int ID { get; set; }
}
}

View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DressAtelierDataModels.Enums
{
public enum OrderStatus
{
Unknown = -1,
Accepted = 0,
InProcess = 1,
Ready = 2,
Given = 3
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DressAtelierDataModels
{
public interface IID
{
int ID { get; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DressAtelierDataModels.Models
{
public interface IDressModel : IID
{
string ProductName { get; }
double Price { get; }
Dictionary<int,(IMaterialModel,int)> ProductComponents { get; }
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DressAtelierDataModels.Models
{
public interface IMaterialModel : IID
{
string ComponentName { get; }
double Cost { get; }
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DressAtelierDataModels.Enums;
namespace DressAtelierDataModels.Models
{
public interface IOrderModel :IID
{
int ProductID { get;}
int Count { get; }
double Sum { get; }
OrderStatus Status { get; }
DateTime DateCreate { get; }
DateTime? DateImplement { get; }
}
}

View File

@ -0,0 +1,31 @@
using DressAtelierListImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DressAtelierListImplement
{
public class DataListSingleton
{
private static DataListSingleton? _instance;
public List<Material> Components { get; set; }
public List<Order> Orders { get; set; }
public List<Dress> Products { get; set; }
private DataListSingleton()
{
Components = new List<Material>();
Orders = new List<Order>();
Products = new List<Dress>();
}
public static DataListSingleton GetInstance()
{
if (_instance == null)
{
_instance = new DataListSingleton();
}
return _instance;
}
}
}

View File

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

View File

@ -0,0 +1,58 @@
using DressAtelierContracts.BindingModels;
using DressAtelierContracts.BusinessLogicContracts;
using DressAtelierContracts.SearchModels;
using DressAtelierContracts.ViewModels;
using DressAtelierDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DressAtelierListImplement.Models
{
public class Dress : IDressModel
{
public int ID { get; private set; }
public string ProductName { get; private set; } = string.Empty;
public double Price { get; private set; }
public Dictionary<int, (IMaterialModel, int)> ProductComponents { get; private set; } = new Dictionary<int, (IMaterialModel, int)>();
public static Dress? Create(DressBindingModel? model)
{
if (model == null)
{
return null;
}
return new Dress()
{
ID = model.ID,
ProductName = model.ProductName,
Price = model.Price,
ProductComponents = model.ProductComponents
};
}
public void Update(DressBindingModel? model)
{
if (model == null)
{
return;
}
ProductName = model.ProductName;
Price = model.Price;
ProductComponents = model.ProductComponents;
}
public DressViewModel GetViewModel => new()
{
ID = ID,
ProductName = ProductName,
Price = Price,
ProductComponents = ProductComponents
};
}
}

View File

@ -0,0 +1,49 @@
using DressAtelierContracts.BindingModels;
using DressAtelierContracts.ViewModels;
using DressAtelierDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DressAtelierListImplement.Models
{
public class Material : IMaterialModel
{
public string ComponentName { get; private set; } = string.Empty;
public double Cost { get; set; }
public int ID { get; private set; }
public static Material? Create(MaterialBindingModel? model)
{
if (model == null)
{
return null;
}
return new Material()
{
ID = model.ID,
ComponentName = model.ComponentName,
Cost = model.Cost
};
}
public void Update(MaterialBindingModel? model)
{
if (model == null)
{
return;
}
ComponentName = model.ComponentName;
Cost = model.Cost;
}
public MaterialViewModel GetViewModel => new()
{
ID = ID,
ComponentName = ComponentName,
Cost = Cost
};
}
}

View File

@ -0,0 +1,76 @@
using DressAtelierContracts.BindingModels;
using DressAtelierContracts.ViewModels;
using DressAtelierDataModels.Enums;
using DressAtelierDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace DressAtelierListImplement.Models
{
public class Order : IOrderModel
{
public int ID { get; private set; }
public int ProductID { get; private set; }
public int Count {get; private set; }
public double Sum { get; private set; }
public OrderStatus Status { get; private set; } = OrderStatus.Unknown;
public DateTime DateCreate { get; private set; } = DateTime.Now;
public DateTime? DateImplement { get; private set; }
public static Order? Create(OrderBindingModel? model)
{
if (model == null)
{
return null;
}
return new Order()
{
ID = model.ID,
ProductID = model.ProductID,
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
DateCreate = model.DateCreate,
DateImplement = model.DateImplement
};
}
public void Update(OrderBindingModel? model)
{
if (model == null)
{
return;
}
ProductID = model.ProductID;
Count = model.Count;
Sum = model.Sum;
Status = model.Status;
DateCreate = model.DateCreate;
}
public OrderViewModel GetViewModel => new()
{
ID = ID,
ProductID = ProductID,
Count = Count,
Sum = Sum,
Status = Status,
DateCreate = DateCreate,
DateImplement = DateImplement
};
}
}

View File

@ -5,6 +5,14 @@ VisualStudioVersion = 17.3.32825.248
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SewingDresses", "SewingDresses.csproj", "{477532B4-09CB-45E7-9AE5-652CAE3E340C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DressAtelierDataModels", "..\DressAtelierDataModels\DressAtelierDataModels.csproj", "{2D48D801-8A00-4FFE-B995-8090A65D0A07}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DressAtelierContracts", "..\DressAtelierContracts\DressAtelierContracts.csproj", "{5500343A-5929-4C91-8509-D0E5F65D19BF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DressAtelierBusinessLogic", "..\DressAtelierBusinessLogic\DressAtelierBusinessLogic.csproj", "{535CDE3E-E0FB-4389-905D-B23C8BA13044}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DressAtelierListImplement", "..\DressAtelierListImplement\DressAtelierListImplement.csproj", "{1A88E277-E50A-45C5-89FA-677EBCD2EF63}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -15,6 +23,22 @@ Global
{477532B4-09CB-45E7-9AE5-652CAE3E340C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{477532B4-09CB-45E7-9AE5-652CAE3E340C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{477532B4-09CB-45E7-9AE5-652CAE3E340C}.Release|Any CPU.Build.0 = Release|Any CPU
{2D48D801-8A00-4FFE-B995-8090A65D0A07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2D48D801-8A00-4FFE-B995-8090A65D0A07}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2D48D801-8A00-4FFE-B995-8090A65D0A07}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2D48D801-8A00-4FFE-B995-8090A65D0A07}.Release|Any CPU.Build.0 = Release|Any CPU
{5500343A-5929-4C91-8509-D0E5F65D19BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5500343A-5929-4C91-8509-D0E5F65D19BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5500343A-5929-4C91-8509-D0E5F65D19BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5500343A-5929-4C91-8509-D0E5F65D19BF}.Release|Any CPU.Build.0 = Release|Any CPU
{535CDE3E-E0FB-4389-905D-B23C8BA13044}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{535CDE3E-E0FB-4389-905D-B23C8BA13044}.Debug|Any CPU.Build.0 = Debug|Any CPU
{535CDE3E-E0FB-4389-905D-B23C8BA13044}.Release|Any CPU.ActiveCfg = Release|Any CPU
{535CDE3E-E0FB-4389-905D-B23C8BA13044}.Release|Any CPU.Build.0 = Release|Any CPU
{1A88E277-E50A-45C5-89FA-677EBCD2EF63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1A88E277-E50A-45C5-89FA-677EBCD2EF63}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1A88E277-E50A-45C5-89FA-677EBCD2EF63}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1A88E277-E50A-45C5-89FA-677EBCD2EF63}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE