Всё во имя демократии
This commit is contained in:
parent
741d60317e
commit
ea17d23db7
@ -1,89 +0,0 @@
|
|||||||
using ElectronicsShopContracts.BindingModels;
|
|
||||||
using ElectronicsShopContracts.BusinessLogicContracts;
|
|
||||||
using ElectronicsShopContracts.SearchModels;
|
|
||||||
using ElectronicsShopContracts.StorageContracts;
|
|
||||||
using ElectronicsShopContracts.ViewModels;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ElectronicsShopBusinessLogic.BusinessLogic
|
|
||||||
{
|
|
||||||
public class CategoryProductLogic : ICategoryProductLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly ICategoryProductStorage _storage;
|
|
||||||
|
|
||||||
public CategoryProductLogic(ILogger<CategoryProductLogic> logger, ICategoryProductStorage storage) {
|
|
||||||
_logger = logger;
|
|
||||||
_storage = storage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Create(CategoryProductBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_storage.Insert(model) == null) {
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Delete(CategoryProductBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model, false);
|
|
||||||
_logger.LogInformation($"Delete. ID:{model.ID}");
|
|
||||||
if (_storage.Delete(model) == null) {
|
|
||||||
_logger.LogWarning("Delete operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public bool Update(CategoryProductBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_storage.Update(model) == null) {
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<CategoryProductViewModel>? ReadList(CategoryProductSearchModel? model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation($"ReadList. ID:{model?.ID}");
|
|
||||||
var list = model == null ? _storage.GetFullList() : _storage.GetFilteredList(model);
|
|
||||||
if (list == null) {
|
|
||||||
_logger.LogWarning("ReadList return null list");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation($"ReadList. Count:{list.Count}");
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CheckModel(CategoryProductBindingModel model, bool withParams = true) {
|
|
||||||
if (model == null) {
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (!withParams) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.Name)) {
|
|
||||||
throw new ArgumentNullException("Нет названия категории продукта", nameof(model.Name));
|
|
||||||
}
|
|
||||||
_logger.LogInformation($"CategoryProduct. ID:{model.ID}.Name:{model.Name}");
|
|
||||||
|
|
||||||
var element = _storage.GetElement(new CategoryProductSearchModel
|
|
||||||
{
|
|
||||||
Name = model.Name
|
|
||||||
});
|
|
||||||
if (element != null && element.Name != model.Name) {
|
|
||||||
throw new InvalidOperationException("Категория с таким названием уже есть");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -12,18 +12,18 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ElectronicsShopBusinessLogic.BusinessLogic
|
namespace ElectronicsShopBusinessLogic.BusinessLogic
|
||||||
{
|
{
|
||||||
internal class UserLogic : IUserLogic
|
internal class ClientLogic : IClientLogic
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IClientStorage _storage;
|
private readonly IClientStorage _storage;
|
||||||
|
|
||||||
public UserLogic(ILogger<UserLogic> logger, IClientStorage storage)
|
public ClientLogic(ILogger<ClientLogic> logger, IClientStorage storage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_storage = storage;
|
_storage = storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Add(UserBindingModel model)
|
public bool Add(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_storage.Insert(model) == null)
|
if (_storage.Insert(model) == null)
|
||||||
@ -34,7 +34,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Update(UserBindingModel model)
|
public bool Update(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_storage.Update(model) == null)
|
if (_storage.Update(model) == null)
|
||||||
@ -45,7 +45,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Delete(UserBindingModel model)
|
public bool Delete(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model, false);
|
CheckModel(model, false);
|
||||||
_logger.LogInformation($"Delete.ID:{model.ID}");
|
_logger.LogInformation($"Delete.ID:{model.ID}");
|
||||||
@ -64,7 +64,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
|
|||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
_logger.LogInformation($"ReadElement.Login:{model.Login}.ID:{model.ID}");
|
_logger.LogInformation($"ReadElement.Email:{model.Email}.ID:{model.ID}");
|
||||||
var element = _storage.GetElement(model);
|
var element = _storage.GetElement(model);
|
||||||
if (element == null)
|
if (element == null)
|
||||||
{
|
{
|
||||||
@ -89,7 +89,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckModel(UserBindingModel model, bool withParams = true)
|
private void CheckModel(ClientBindingModel model, bool withParams = true)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
@ -99,41 +99,27 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(model.Login))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет логина пользователя", nameof(model.Login));
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.FirstName))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет имени пользователя", nameof(model.FirstName));
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.LastName))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет фамилии пользоватея", nameof(model.LastName));
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.Email))
|
if (string.IsNullOrEmpty(model.Email))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Нет почты клиента", nameof(model.Email));
|
throw new ArgumentNullException("Нет почты пользователя", nameof(model.Email));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.ClientFIO))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет имени пользователя", nameof(model.ClientFIO));
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(model.Password))
|
if (string.IsNullOrEmpty(model.Password))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Нет пароля пользователя", nameof(model.Password));
|
throw new ArgumentNullException("Нет пароля пользователя", nameof(model.Password));
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(model.PhoneNumber))
|
_logger.LogInformation($"Client. ID:{model.ID}.ClientFIO:{model.ClientFIO}.Password:{model.Password}.Email:{model.Email}.");
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет номер телефона пользователя", nameof(model.PhoneNumber));
|
|
||||||
}
|
|
||||||
_logger.LogInformation($"Client. ID:{model.ID}.RoleID:{model.RoleID}.FirstName:{model.FirstName}." +
|
|
||||||
$"LastName:{model.LastName}.Password:{model.Password}.PhoneNumber:{model.PhoneNumber}.Login:{model.Login}." +
|
|
||||||
$"Email:{model.Email}");
|
|
||||||
|
|
||||||
var element = _storage.GetElement(new ClientSearchModel
|
var element = _storage.GetElement(new ClientSearchModel
|
||||||
{
|
{
|
||||||
Login = model.Login
|
Email= model.Email
|
||||||
});
|
});
|
||||||
if (element != null && element.Login != model.Login)
|
if (element != null && element.Email != model.Email)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Клиент с таким логином уже есть");
|
throw new InvalidOperationException("Клиент с такой почтой уже есть");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,102 @@
|
|||||||
|
using ElectronicsShopContracts.BindingModels;
|
||||||
|
using ElectronicsShopContracts.BusinessLogicContracts;
|
||||||
|
using ElectronicsShopContracts.SearchModels;
|
||||||
|
using ElectronicsShopContracts.StorageContracts;
|
||||||
|
using ElectronicsShopContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
|
||||||
|
namespace ElectronicsShopBusinessLogic.BusinessLogic
|
||||||
|
{
|
||||||
|
public class CostItemLogic : ICostItemLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly ICostItemStorage _storage;
|
||||||
|
|
||||||
|
public bool Create(CostItemBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_storage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Add operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(CostItemBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation($"Delete.ID:{model.ID}");
|
||||||
|
if (_storage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CostItemViewModel? ReadElement(CostItemSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation($"ReadElement.Name:{model.Name}.ID:{model.ID}");
|
||||||
|
var element = _storage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement. element not fount");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation($"ReadElement.find.ID:{element.ID}");
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CostItemViewModel>? ReadList(CostItemSearchModel model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation($"ReadList. ClientID:{model?.ID}");
|
||||||
|
var list = model == null ? _storage.GetFullList() : _storage.GetFillteredList(model); ;
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList. return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation($"ReadList.Count:{list.Count}");
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(CostItemBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_storage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(CostItemBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (model.Price <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Цена продукта должна быть больше 0", nameof(model.Price));
|
||||||
|
}
|
||||||
|
_logger.LogInformation($"CostItem. ID:{model.ID}.EmployeeID:{model.EmployeeID}.Name:{model.Name}.Price:{model.Price}");
|
||||||
|
var element = _storage.GetElement(new CostItemSearchModel { ID = model.ID });
|
||||||
|
if (element != null && element.EmployeeID != model.EmployeeID)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Продукт с таким названием уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,117 @@
|
|||||||
|
using ElectronicsShopContracts.BindingModels;
|
||||||
|
using ElectronicsShopContracts.BusinessLogicContracts;
|
||||||
|
using ElectronicsShopContracts.SearchModels;
|
||||||
|
using ElectronicsShopContracts.StorageContracts;
|
||||||
|
using ElectronicsShopContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ElectronicsShopBusinessLogic.BusinessLogic
|
||||||
|
{
|
||||||
|
public class EmployeeLogic : IEmployeeLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IEmployeeStorage _storage;
|
||||||
|
|
||||||
|
public bool Add(EmployeeBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_storage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Add operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(EmployeeBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation($"Delete.ID:{model.ID}");
|
||||||
|
if (_storage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmployeeViewModel? ReadElemet(EmployeeSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation($"ReadElement.Login:{model.Login}.ID:{model.ID}");
|
||||||
|
var element = _storage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement. element not fount");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation($"ReadElement.find.ID:{element.ID}");
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<EmployeeViewModel>? ReadList(EmployeeSearchModel model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation($"ReadList. ClientID:{model?.ID}");
|
||||||
|
var list = model == null ? _storage.GetFullList() : _storage.GetFilteredList(model); ;
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList. return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation($"ReadList.Count:{list.Count}");
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(EmployeeBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_storage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
private void CheckModel(EmployeeBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Login))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет логина пользователя", nameof(model.Login));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.EmployeeFIO))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет имени пользователя", nameof(model.EmployeeFIO));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Password))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет пароля пользователя", nameof(model.Password));
|
||||||
|
}
|
||||||
|
_logger.LogInformation($"Client. ID:{model.ID}.ClientFIO:{model.EmployeeFIO}.Password:{model.Password}.Email:{model.Login}.");
|
||||||
|
|
||||||
|
var element = _storage.GetElement(new EmployeeSearchModel
|
||||||
|
{
|
||||||
|
Login = model.Login
|
||||||
|
});
|
||||||
|
if (element != null && element.Login != model.Login)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Клиент с такой почтой уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -25,29 +25,12 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
|
|||||||
public bool CreateOrder(OrderBindingModel model)
|
public bool CreateOrder(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
model.Status = OrderStatus.Принят;
|
|
||||||
if (_storage.Insert(model) == null) {
|
if (_storage.Insert(model) == null) {
|
||||||
_logger.LogInformation("Insert operation failed");
|
_logger.LogInformation("Insert operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DeliveryOrder(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
return StatusUpdate(model, OrderStatus.Выдан);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool FinishOrder(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
return StatusUpdate(model, OrderStatus.Готов);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool TakeOrderInWork(OrderBindingModel model)
|
|
||||||
{
|
|
||||||
return StatusUpdate(model, OrderStatus.Выполняется);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||||
{
|
{
|
||||||
_logger.LogInformation($"ReadList:ID:{model?.ID}");
|
_logger.LogInformation($"ReadList:ID:{model?.ID}");
|
||||||
@ -73,37 +56,21 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
|
|||||||
if (model.Sum <= 0) {
|
if (model.Sum <= 0) {
|
||||||
throw new ArgumentNullException("Цена зака должна быть больше 0", nameof(model.Sum));
|
throw new ArgumentNullException("Цена зака должна быть больше 0", nameof(model.Sum));
|
||||||
}
|
}
|
||||||
_logger.LogInformation($"Order. ID:{model.ID}.Sum:{model.Sum}.Status:{model.Status}.PaymeantOption:{model.PaymeantOption}." +
|
_logger.LogInformation($"Order. ID:{model.ID}.Sum:{model.Sum}.DateCreate:{model.DateCreate}.");
|
||||||
$"DateCreate:{model.DateCreate}.DataImplement:{model.DateImplement}");
|
|
||||||
}
|
|
||||||
private bool StatusUpdate(OrderBindingModel model, OrderStatus newOrderStatus)
|
|
||||||
{
|
|
||||||
CheckModel(model, false);
|
|
||||||
var viewModel = _storage.GetElement(new OrderSearchModel { ID = model.ID });
|
|
||||||
if (viewModel == null) {
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (viewModel.OrderStatus + 1 != newOrderStatus) {
|
|
||||||
_logger.LogWarning("Status update to " + newOrderStatus.ToString() + " operation failed.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
model.Status = newOrderStatus;
|
|
||||||
if (model.Status == OrderStatus.Готов) {
|
|
||||||
model.DateImplement = DateTime.Now;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
model.DateImplement = viewModel.DateImplement;
|
|
||||||
}
|
|
||||||
if (_storage.Update(model) == null) {
|
|
||||||
_logger.LogWarning("Update operarion failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? ReadElement(OrderSearchModel model)
|
public OrderViewModel? ReadElement(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
if (model == null) throw new ArgumentNullException(nameof(model));
|
||||||
|
_logger.LogInformation($"ReadElement. ID:{model.ID}");
|
||||||
|
var element = _storage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement. elementn not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation($"ReadElement find. ID:{element.ID}");
|
||||||
|
return element;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,17 +15,66 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
|
|||||||
|
|
||||||
public bool CreatePay(PaymentBindingModel model)
|
public bool CreatePay(PaymentBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
CheckModel(model);
|
||||||
|
if (_storage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PaymentViewModel? ReadElement(PaymentSearchModel model)
|
public PaymentViewModel? ReadElement(PaymentSearchModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation($"ReadElement.ProductID:{model.ProductID}.ID:{model.ID}");
|
||||||
|
var element = _storage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement. element not fount");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation($"ReadElement.find.ID:{element.ID}");
|
||||||
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PaymentViewModel>? ReadList(PaymentSearchModel? model)
|
public List<PaymentViewModel>? ReadList(PaymentSearchModel? model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
_logger.LogInformation($"ReadList. ClientID:{model?.ID}");
|
||||||
|
/*var list = model == null ? _storage.GetFullList() : _storage.GetFillteredList(model); ;
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList. return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation($"ReadList.Count:{list.Count}");*/
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(PaymentBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (model.SumPayment <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Цена продукта должна быть больше 0", nameof(model.SumPayment));
|
||||||
|
}
|
||||||
|
_logger.LogInformation($"Payment. ID:{model.ID}.ProductID:{model.ProductID}.Sum:{model.SumPayment}.OrderID:{model.OrderID}.PayOption{model.PayOption}");
|
||||||
|
var element = _storage.GetElement(new PaymentSearchModel { ID = model.ID });
|
||||||
|
if (element != null && element.PayOption != model.PayOption)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Продукт с таким названием уже есть");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ using ElectronicsShopContracts.BusinessLogicContracts;
|
|||||||
using ElectronicsShopContracts.SearchModels;
|
using ElectronicsShopContracts.SearchModels;
|
||||||
using ElectronicsShopContracts.StorageContracts;
|
using ElectronicsShopContracts.StorageContracts;
|
||||||
using ElectronicsShopContracts.ViewModels;
|
using ElectronicsShopContracts.ViewModels;
|
||||||
|
using ElectronicsShopDataModels.Enums;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -95,8 +96,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
|
|||||||
if (model.Price <= 0) {
|
if (model.Price <= 0) {
|
||||||
throw new ArgumentNullException("Цена продукта должна быть больше 0", nameof(model.Price));
|
throw new ArgumentNullException("Цена продукта должна быть больше 0", nameof(model.Price));
|
||||||
}
|
}
|
||||||
_logger.LogInformation($"Product. ID:{model.ID}.ProductName:{model.ProductName}.Price:{model.Price}" +
|
_logger.LogInformation($"Product. ID:{model.ID}.ProductName:{model.ProductName}.Price:{model.Price}.CostItemID:{model.CostItemID}");
|
||||||
$".CategoryID:{model.CategoryID}");
|
|
||||||
var element = _storage.GetElement(new ProductSearchModel { ProductName = model.ProductName });
|
var element = _storage.GetElement(new ProductSearchModel { ProductName = model.ProductName });
|
||||||
if (element != null && element.ProductName != model.ProductName) {
|
if (element != null && element.ProductName != model.ProductName) {
|
||||||
throw new InvalidOperationException("Продукт с таким названием уже есть");
|
throw new InvalidOperationException("Продукт с таким названием уже есть");
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
using ElectronicsShopContracts.BindingModels;
|
|
||||||
using ElectronicsShopContracts.BusinessLogicContracts;
|
|
||||||
using ElectronicsShopContracts.SearchModels;
|
|
||||||
using ElectronicsShopContracts.StorageContracts;
|
|
||||||
using ElectronicsShopContracts.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ElectronicsShopBusinessLogic.BusinessLogic
|
|
||||||
{
|
|
||||||
public class ReportLogic : IReportLogic
|
|
||||||
{
|
|
||||||
private readonly IOrderStorage _orderStorage;
|
|
||||||
private readonly IProductStorage _productStorag;
|
|
||||||
|
|
||||||
public ReportLogic(IOrderStorage orderStorage, IProductStorage productStorag) {
|
|
||||||
_orderStorage = orderStorage;
|
|
||||||
_productStorag = productStorag;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Получение списка заказов за определенный период
|
|
||||||
public List<ReportOrdersViewModel> GetOrders(ReportBindingModel model) {
|
|
||||||
return _orderStorage.GetFilteredList(new OrderSearchModel {
|
|
||||||
DateFrom = model.DateFrom,
|
|
||||||
DateTo = model.DateTo,
|
|
||||||
}).Select(x => new ReportOrdersViewModel {
|
|
||||||
ID = x.ID,
|
|
||||||
DateCreate = x.DateCreate,
|
|
||||||
Sum = x.Sum,
|
|
||||||
PaymeantOption = x.PaymeantOption.ToString(),
|
|
||||||
OrderStatus = x.Status.ToString(),
|
|
||||||
}).ToList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,99 +0,0 @@
|
|||||||
using ElectronicsShopContracts.BindingModels;
|
|
||||||
using ElectronicsShopContracts.BusinessLogicContracts;
|
|
||||||
using ElectronicsShopContracts.SearchModels;
|
|
||||||
using ElectronicsShopContracts.StorageContracts;
|
|
||||||
using ElectronicsShopContracts.ViewModels;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ElectronicsShopBusinessLogic.BusinessLogic
|
|
||||||
{
|
|
||||||
public class RoleLogic : IRoleLogic
|
|
||||||
{
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly IRoleStorage _storage;
|
|
||||||
|
|
||||||
public RoleLogic(ILogger<RoleLogic> logger, IRoleStorage storage)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_storage = storage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Create(RoleBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_storage.Insert(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Insert operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Delete(RoleBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model, false);
|
|
||||||
_logger.LogInformation($"Delete. ID:{model.ID}");
|
|
||||||
if (_storage.Delete(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Delete operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public bool Update(RoleBindingModel model)
|
|
||||||
{
|
|
||||||
CheckModel(model);
|
|
||||||
if (_storage.Update(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<RoleViewModel>? ReadList(RoleSearchModel? model)
|
|
||||||
{
|
|
||||||
_logger.LogInformation($"ReadList. ID:{model?.ID}");
|
|
||||||
var list = model == null ? _storage.GetFullList() : _storage.GetFilteredList(model);
|
|
||||||
if (list == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("ReadList return null list");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_logger.LogInformation($"ReadList. Count:{list.Count}");
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CheckModel(RoleBindingModel model, bool withParams = true)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(model));
|
|
||||||
}
|
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.Name))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Нет названия категории продукта", nameof(model.Name));
|
|
||||||
}
|
|
||||||
_logger.LogInformation($"CategoryProduct. ID:{model.ID}.Name:{model.Name}");
|
|
||||||
|
|
||||||
var element = _storage.GetElement(new RoleSearchModel
|
|
||||||
{
|
|
||||||
Name = model.Name
|
|
||||||
});
|
|
||||||
if (element != null && element.Name != model.Name)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Такая роль уже есть");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -9,7 +9,7 @@ namespace ElectronicsShopContracts.BindingModels {
|
|||||||
public class CostItemBindingModel : ICostItemModel {
|
public class CostItemBindingModel : ICostItemModel {
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
public int ClientID { get; set; }
|
public int EmployeeID { get; set; }
|
||||||
|
|
||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using ElectronicsShopDataModels.Models;
|
using ElectronicsShopDataModels.Enums;
|
||||||
|
using ElectronicsShopDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -11,12 +12,12 @@ namespace ElectronicsShopContracts.BindingModels
|
|||||||
{
|
{
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
public int ClientID { get; set; }
|
|
||||||
|
|
||||||
public int ProductID { get; set; }
|
public int ProductID { get; set; }
|
||||||
|
|
||||||
public int OrderID { get; set; }
|
public int OrderID { get; set; }
|
||||||
|
|
||||||
public double SumPayment { get; set; }
|
public double SumPayment { get; set; }
|
||||||
|
|
||||||
|
public PaymeantOption PayOption { get; set; } = PaymeantOption.Неизвестно;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,5 @@ namespace ElectronicsShopContracts.BindingModels
|
|||||||
public string ProductName { get; set; } = string.Empty;
|
public string ProductName { get; set; } = string.Empty;
|
||||||
|
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
|
||||||
public PaymeantOption PayOption { get; set; } = PaymeantOption.Неизвестно;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,5 +18,6 @@ namespace ElectronicsShopContracts.StorageContracts
|
|||||||
EmployeeViewModel? Insert(EmployeeBindingModel model);
|
EmployeeViewModel? Insert(EmployeeBindingModel model);
|
||||||
EmployeeViewModel? Update(EmployeeBindingModel model);
|
EmployeeViewModel? Update(EmployeeBindingModel model);
|
||||||
EmployeeViewModel? Delete(EmployeeBindingModel model);
|
EmployeeViewModel? Delete(EmployeeBindingModel model);
|
||||||
|
object GetElement(CostItemSearchModel costItemSearchModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ namespace ElectronicsShopContracts.ViewModels {
|
|||||||
public class CostItemViewModel : ICostItemModel {
|
public class CostItemViewModel : ICostItemModel {
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
public int ClientID { get; set; }
|
public int EmployeeID { get; set; }
|
||||||
|
|
||||||
[DisplayName("Название статьи затрат")]
|
[DisplayName("Название статьи затрат")]
|
||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using ElectronicsShopDataModels.Models;
|
using ElectronicsShopDataModels.Enums;
|
||||||
|
using ElectronicsShopDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -17,5 +18,8 @@ namespace ElectronicsShopContracts.ViewModels
|
|||||||
|
|
||||||
[DisplayName("Cумма оплаты продукта")]
|
[DisplayName("Cумма оплаты продукта")]
|
||||||
public double SumPayment { get; set; }
|
public double SumPayment { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("Статус оплаты")]
|
||||||
|
public PaymeantOption PayOption { get; set; } = PaymeantOption.Неизвестно;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,5 @@ namespace ElectronicsShopContracts.ViewModels
|
|||||||
[DisplayName("Стоимость продукта")]
|
[DisplayName("Стоимость продукта")]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
|
||||||
[DisplayName("Статус оплаты")]
|
|
||||||
public PaymeantOption PayOption { get; set; } = PaymeantOption.Неизвестно;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,6 @@ namespace ElectronicsShopDataBaseImplement.Models
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ID = model.ID;
|
|
||||||
ClientFIO = model.ClientFIO;
|
ClientFIO = model.ClientFIO;
|
||||||
Password = model.Password;
|
Password = model.Password;
|
||||||
Email = model.Email;
|
Email = model.Email;
|
||||||
|
@ -15,7 +15,7 @@ namespace ElectronicsShopDataBaseImplement.Models
|
|||||||
{
|
{
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
[ForeignKey("ClientID")]
|
[ForeignKey("ClientID")]
|
||||||
public int ClientID { get; set; }
|
public int EmployeeID { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public string Name { get; set; }= string.Empty;
|
public string Name { get; set; }= string.Empty;
|
||||||
[Required]
|
[Required]
|
||||||
@ -30,7 +30,7 @@ namespace ElectronicsShopDataBaseImplement.Models
|
|||||||
return new CostItem()
|
return new CostItem()
|
||||||
{
|
{
|
||||||
ID = model.ID,
|
ID = model.ID,
|
||||||
ClientID = model.ClientID,
|
EmployeeID = model.EmployeeID,
|
||||||
Name = model.Name,
|
Name = model.Name,
|
||||||
Price = model.Price,
|
Price = model.Price,
|
||||||
};
|
};
|
||||||
@ -41,8 +41,7 @@ namespace ElectronicsShopDataBaseImplement.Models
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ID = model.ID;
|
EmployeeID = model.EmployeeID;
|
||||||
ClientID = model.ClientID;
|
|
||||||
Name = model.Name;
|
Name = model.Name;
|
||||||
Price = model.Price;
|
Price = model.Price;
|
||||||
}
|
}
|
||||||
@ -50,7 +49,7 @@ namespace ElectronicsShopDataBaseImplement.Models
|
|||||||
public CostItemViewModel GetViewModel => new()
|
public CostItemViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
ID = ID,
|
ID = ID,
|
||||||
ClientID = ClientID,
|
EmployeeID = EmployeeID,
|
||||||
Name = Name,
|
Name = Name,
|
||||||
Price = Price,
|
Price = Price,
|
||||||
};
|
};
|
||||||
|
@ -42,7 +42,6 @@ namespace ElectronicsShopDataBaseImplement.Models
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ID = model.ID;
|
|
||||||
EmployeeFIO = model.EmployeeFIO;
|
EmployeeFIO = model.EmployeeFIO;
|
||||||
Login = model.Login;
|
Login = model.Login;
|
||||||
Password = model.Password;
|
Password = model.Password;
|
||||||
|
@ -66,7 +66,6 @@ namespace ElectronicsShopDataBaseImplement.Models
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ID = model.ID;
|
|
||||||
ClientID = model.ClientID;
|
ClientID = model.ClientID;
|
||||||
Sum = model.Sum;
|
Sum = model.Sum;
|
||||||
EmployeeID = model.EmployeeID;
|
EmployeeID = model.EmployeeID;
|
||||||
|
@ -0,0 +1,64 @@
|
|||||||
|
using ElectronicsShopContracts.BindingModels;
|
||||||
|
using ElectronicsShopContracts.ViewModels;
|
||||||
|
using ElectronicsShopDataModels.Enums;
|
||||||
|
using ElectronicsShopDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ElectronicsShopDataBaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Payment : IPaymentModel
|
||||||
|
{
|
||||||
|
public int ID { get; set; }
|
||||||
|
[ForeignKey("ProductID")]
|
||||||
|
public int ProductID { get; set; }
|
||||||
|
[ForeignKey("OrderID")]
|
||||||
|
public int OrderID { get; set; }
|
||||||
|
[Required]
|
||||||
|
public double SumPayment { get; set; }
|
||||||
|
[Required]
|
||||||
|
public PaymeantOption PayOption { get; set; } = PaymeantOption.Неизвестно;
|
||||||
|
public static Payment? Create(PaymentBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Payment()
|
||||||
|
{
|
||||||
|
ID = model.ID,
|
||||||
|
ProductID = model.ProductID,
|
||||||
|
OrderID = model.OrderID,
|
||||||
|
SumPayment = model.SumPayment,
|
||||||
|
PayOption = model.PayOption,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(PaymentBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ProductID = model.ProductID;
|
||||||
|
OrderID = model.OrderID;
|
||||||
|
SumPayment = model.SumPayment;
|
||||||
|
PayOption = model.PayOption;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PaymentViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
ID = ID,
|
||||||
|
ProductID = ProductID,
|
||||||
|
OrderID = OrderID,
|
||||||
|
SumPayment = SumPayment,
|
||||||
|
PayOption = PayOption,
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -21,7 +21,6 @@ namespace ElectronicsShopDataBaseImplement.Models
|
|||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
[ForeignKey("CostItemID")]
|
[ForeignKey("CostItemID")]
|
||||||
public int CostItemID { get; set; }
|
public int CostItemID { get; set; }
|
||||||
public PaymeantOption PayOption { get; set; } = PaymeantOption.Неизвестно;
|
|
||||||
|
|
||||||
public static Product? Create(ProductBindingModel? model)
|
public static Product? Create(ProductBindingModel? model)
|
||||||
{
|
{
|
||||||
@ -35,7 +34,6 @@ namespace ElectronicsShopDataBaseImplement.Models
|
|||||||
ProductName = model.ProductName,
|
ProductName = model.ProductName,
|
||||||
Price = model.Price,
|
Price = model.Price,
|
||||||
CostItemID=model.CostItemID,
|
CostItemID=model.CostItemID,
|
||||||
PayOption=model.PayOption
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public void Update(ProductBindingModel model)
|
public void Update(ProductBindingModel model)
|
||||||
@ -44,11 +42,9 @@ namespace ElectronicsShopDataBaseImplement.Models
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ID = model.ID;
|
|
||||||
ProductName = model.ProductName;
|
ProductName = model.ProductName;
|
||||||
Price = model.Price;
|
Price = model.Price;
|
||||||
CostItemID = model.CostItemID;
|
CostItemID = model.CostItemID;
|
||||||
PayOption = model.PayOption;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProductViewModel GetViewModel => new()
|
public ProductViewModel GetViewModel => new()
|
||||||
@ -57,7 +53,6 @@ namespace ElectronicsShopDataBaseImplement.Models
|
|||||||
ProductName = ProductName,
|
ProductName = ProductName,
|
||||||
Price = Price,
|
Price = Price,
|
||||||
CostItemID = CostItemID,
|
CostItemID = CostItemID,
|
||||||
PayOption = PayOption
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ElectronicsShopDataModels.Models {
|
namespace ElectronicsShopDataModels.Models {
|
||||||
public interface ICostItemModel : IID{
|
public interface ICostItemModel : IID{
|
||||||
int ClientID { get; }
|
int EmployeeID { get; }
|
||||||
string Name { get; }
|
string Name { get; }
|
||||||
double Price { get; }
|
double Price { get; }
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.VisualBasic;
|
using ElectronicsShopDataModels.Enums;
|
||||||
|
using Microsoft.VisualBasic;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -12,6 +13,7 @@ namespace ElectronicsShopDataModels.Models
|
|||||||
int ProductID { get; }
|
int ProductID { get; }
|
||||||
int OrderID { get; }
|
int OrderID { get; }
|
||||||
double SumPayment { get; }
|
double SumPayment { get; }
|
||||||
|
PaymeantOption PayOption { get; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,6 @@ namespace ElectronicsShopDataModels.Models
|
|||||||
string ProductName { get; }
|
string ProductName { get; }
|
||||||
double Price { get; }
|
double Price { get; }
|
||||||
int CostItemID { get; }
|
int CostItemID { get; }
|
||||||
PaymeantOption PayOption { get; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user