Contractor: BusinessLogic and Fixes in Contracts and DataModels
This commit is contained in:
parent
a31e821be3
commit
ff3957a457
105
ComputerStoreBusinessLogic/BusinessLogic/ConsignmentLogic.cs
Normal file
105
ComputerStoreBusinessLogic/BusinessLogic/ConsignmentLogic.cs
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
using ComputerStoreContracts.BindingModels;
|
||||||
|
using ComputerStoreContracts.BusinessLogicContracts;
|
||||||
|
using ComputerStoreContracts.SearchModels;
|
||||||
|
using ComputerStoreContracts.StorageContracts;
|
||||||
|
using ComputerStoreContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ComputerStoreBusinessLogic.BusinessLogic
|
||||||
|
{
|
||||||
|
public class ConsignmentLogic : IConsignmentLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IConsignmentStorage _consignmentStorage;
|
||||||
|
public ConsignmentLogic(ILogger<ConsignmentLogic> logger, IConsignmentStorage consignmentStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_consignmentStorage = consignmentStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(ConsignmentBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_consignmentStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(ConsignmentBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_consignmentStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(ConsignmentBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation("Delete. ID:{ID}", model.ID);
|
||||||
|
if (_consignmentStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConsignmentViewModel? ReadElement(ConsignmentSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("ReadElement. Consignment ID:{ ID}", model.ID);
|
||||||
|
|
||||||
|
var element = _consignmentStorage.GetElement(model);
|
||||||
|
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement element not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("ReadElement find. Consignment ID:{ID}", element.ID);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ConsignmentViewModel>? ReadList(ConsignmentSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("ReadList. Consignment ID:{ ID}", model?.ID);
|
||||||
|
|
||||||
|
var list = model == null ? _consignmentStorage.GetFullList() : _consignmentStorage.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(ConsignmentBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null) { return; }
|
||||||
|
if (!withParams) { return; }
|
||||||
|
if (model.Price <= 0) { throw new ArgumentNullException("Invalid consignment's price", nameof(model)); }
|
||||||
|
if (string.IsNullOrEmpty(model.OrderID.ToString())) { throw new ArgumentNullException("Invalid Consignment's order ID", nameof(model)); }
|
||||||
|
|
||||||
|
_logger.LogInformation("Consignment. Consignment ID:{ ID}. Order ID:{ OrderID}.", model.ID, model.OrderID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
148
ComputerStoreBusinessLogic/BusinessLogic/OrderLogic.cs
Normal file
148
ComputerStoreBusinessLogic/BusinessLogic/OrderLogic.cs
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
using ComputerStoreContracts.BindingModels;
|
||||||
|
using ComputerStoreContracts.BusinessLogicContracts;
|
||||||
|
using ComputerStoreContracts.SearchModels;
|
||||||
|
using ComputerStoreContracts.StorageContracts;
|
||||||
|
using ComputerStoreContracts.ViewModels;
|
||||||
|
using ComputerStoreDataModels.Enums;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ComputerStoreBusinessLogic.BusinessLogic
|
||||||
|
{
|
||||||
|
public class OrderLogic : IOrderLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IOrderStorage _orderStorage;
|
||||||
|
|
||||||
|
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_orderStorage = orderStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CreateOrder(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (model.Status != OrderStatus.Unknown)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed. Order status incorrect.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
model.Status = OrderStatus.Accepted;
|
||||||
|
if (_orderStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
model.Status = OrderStatus.Unknown;
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool StatusUpdate(OrderBindingModel rawModel, OrderStatus newStatus)
|
||||||
|
{
|
||||||
|
var viewModel = _orderStorage.GetElement(new OrderSearchModel
|
||||||
|
{
|
||||||
|
ID = rawModel.ID
|
||||||
|
});
|
||||||
|
|
||||||
|
if (viewModel == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Order model not found");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
OrderBindingModel model = new OrderBindingModel
|
||||||
|
{
|
||||||
|
ID = viewModel.ID,
|
||||||
|
ConsignmentID = viewModel.ConsignmentID,
|
||||||
|
RequestID = viewModel.RequestID,
|
||||||
|
Status = viewModel.Status,
|
||||||
|
DateCreate = viewModel.DateCreate,
|
||||||
|
DateImplement = viewModel.DateImplement,
|
||||||
|
Price = viewModel.Price
|
||||||
|
};
|
||||||
|
|
||||||
|
CheckModel(model, false);
|
||||||
|
if (model.Status + 1 != newStatus)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
model.Status = newStatus;
|
||||||
|
if (model.Status == OrderStatus.Given) model.DateImplement = DateTime.Now;
|
||||||
|
if (_orderStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
model.Status--;
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool TakeOrderInProcess(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
return StatusUpdate(model, OrderStatus.InProcess);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool TakeOrderReady(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
return StatusUpdate(model, OrderStatus.Ready);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool TakeOrderGiven(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
return StatusUpdate(model, OrderStatus.Given);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Order. 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.RequestID.ToString()) && string.IsNullOrEmpty(model.ConsignmentID.ToString()))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Incorrect consignment or request ID", nameof(model.ConsignmentID));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(model.RequestID.ToString()) && model.ConsignmentID < 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Incorrect consignment ID", nameof(model.ConsignmentID));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.ConsignmentID.ToString()) && model.RequestID < 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Incorrect request ID", nameof(model.RequestID));
|
||||||
|
}
|
||||||
|
if (model.Price <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Incorrect Price", nameof(model.Price));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.SellerID.ToString()) && model.SellerID < 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Incorrect seller ID", nameof(model.SellerID));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Order. OrderID:{ ID}.RequestID:{ RequestID}. ConsignmentID: { ConsignmentID}. SellerID: { SellerID}", model.ID, model.RequestID, model.ConsignmentID, model.SellerID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
105
ComputerStoreBusinessLogic/BusinessLogic/RequestLogic.cs
Normal file
105
ComputerStoreBusinessLogic/BusinessLogic/RequestLogic.cs
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
using ComputerStoreContracts.BindingModels;
|
||||||
|
using ComputerStoreContracts.BusinessLogicContracts;
|
||||||
|
using ComputerStoreContracts.SearchModels;
|
||||||
|
using ComputerStoreContracts.StorageContracts;
|
||||||
|
using ComputerStoreContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ComputerStoreBusinessLogic.BusinessLogic
|
||||||
|
{
|
||||||
|
public class RequestLogic : IRequestLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IRequestStorage _requestStorage;
|
||||||
|
public RequestLogic(ILogger<RequestLogic> logger, IRequestStorage requestStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_requestStorage = requestStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(RequestBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_requestStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(RequestBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_requestStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(RequestBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation("Delete. ID:{ID}", model.ID);
|
||||||
|
if (_requestStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RequestViewModel? ReadElement(RequestSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("ReadElement. Request ID:{ ID}. Order ID:{ OrderID}", model.ID, model.OrderID);
|
||||||
|
|
||||||
|
var element = _requestStorage.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<RequestViewModel>? ReadList(RequestSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("ReadList. Request ID:{ ID}. Order ID: { OrderID}", model?.ID, model?.OrderID);
|
||||||
|
|
||||||
|
var list = model == null ? _requestStorage.GetFullList() : _requestStorage.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(RequestBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null) { return; }
|
||||||
|
if (!withParams) { return; }
|
||||||
|
if (model.Price <= 0) { throw new ArgumentNullException("Invalid request's price", nameof(model)); }
|
||||||
|
if (string.IsNullOrEmpty(model.OrderID.ToString())) { throw new ArgumentNullException("Invalid Request's order ID", nameof(model)); }
|
||||||
|
|
||||||
|
_logger.LogInformation("Request. Request ID:{ ID}. Order ID: { OrderID}", model.ID, model.OrderID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
122
ComputerStoreBusinessLogic/BusinessLogic/SellerLogic.cs
Normal file
122
ComputerStoreBusinessLogic/BusinessLogic/SellerLogic.cs
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
using ComputerStoreContracts.BindingModels;
|
||||||
|
using ComputerStoreContracts.BusinessLogicContracts;
|
||||||
|
using ComputerStoreContracts.SearchModels;
|
||||||
|
using ComputerStoreContracts.StorageContracts;
|
||||||
|
using ComputerStoreContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ComputerStoreBusinessLogic.BusinessLogic
|
||||||
|
{
|
||||||
|
public class SellerLogic : ISellerLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly ISellerStorage _sellerStorage;
|
||||||
|
public SellerLogic(ILogger<SellerLogic> logger, ISellerStorage sellerStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_sellerStorage = sellerStorage;
|
||||||
|
}
|
||||||
|
public bool Create(SellerBindingModel model)
|
||||||
|
{
|
||||||
|
CheckSeller(model);
|
||||||
|
if (_sellerStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(SellerBindingModel model)
|
||||||
|
{
|
||||||
|
CheckSeller(model);
|
||||||
|
if (_sellerStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(SellerBindingModel model)
|
||||||
|
{
|
||||||
|
CheckSeller(model, false);
|
||||||
|
_logger.LogInformation("Delete. ID:{ID}", model.ID);
|
||||||
|
if (_sellerStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SellerViewModel? ReadElement(SellerSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement. Username:{Username}.ID:{ ID}", model.Username, model.ID);
|
||||||
|
var element = _sellerStorage.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<SellerViewModel>? ReadList(SellerSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("ReadList. Username:{Username}. ID:{ ID}", model?.Username, model?.ID);
|
||||||
|
|
||||||
|
var list = model == null ? _sellerStorage.GetFullList() : _sellerStorage.GetFilteredList(model);
|
||||||
|
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CheckSeller(SellerBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Username))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Invalid username of user", nameof(model.Username));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Password))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Invalid password of user", nameof(model.Password));
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Client. Username:{ Username}. ID: { ID} ", model.Username, model.ID);
|
||||||
|
|
||||||
|
var element = _sellerStorage.GetElement(new SellerSearchModel
|
||||||
|
{
|
||||||
|
Username = model.Username
|
||||||
|
});
|
||||||
|
|
||||||
|
if (element != null && element.ID != model.ID)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Seller with such username already exists.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -9,9 +9,8 @@ namespace ComputerStoreContracts.BindingModels
|
|||||||
{
|
{
|
||||||
public class ConsignmentBindingModel : IConsignmentModel
|
public class ConsignmentBindingModel : IConsignmentModel
|
||||||
{
|
{
|
||||||
|
public int ID { get; set; }
|
||||||
public int OrderID { get; set; }
|
public int OrderID { get; set; }
|
||||||
public int ProductID { get; set; }
|
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
public int Count { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,8 @@ namespace ComputerStoreContracts.BindingModels
|
|||||||
{
|
{
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
public OrderType Type { get; set; } = OrderType.Unknown;
|
public int? ConsignmentID { get; set; }
|
||||||
|
public int? RequestID { get; set; }
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Unknown;
|
public OrderStatus Status { get; set; } = OrderStatus.Unknown;
|
||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
|
@ -12,6 +12,5 @@ namespace ComputerStoreContracts.BindingModels
|
|||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
public int OrderID { get; set; }
|
public int OrderID { get; set; }
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
public int Count { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,9 @@ namespace ComputerStoreContracts.BusinessLogicContracts
|
|||||||
public interface IOrderLogic
|
public interface IOrderLogic
|
||||||
{
|
{
|
||||||
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
||||||
OrderViewModel? ReadElement(OrderSearchModel model);
|
bool CreateOrder(OrderBindingModel model);
|
||||||
bool Create(OrderBindingModel model);
|
bool TakeOrderInProcess(OrderBindingModel model);
|
||||||
bool Update(OrderBindingModel model);
|
bool TakeOrderReady(OrderBindingModel model);
|
||||||
bool Delete(OrderBindingModel model);
|
bool TakeOrderGiven(OrderBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ namespace ComputerStoreContracts.SearchModels
|
|||||||
{
|
{
|
||||||
public class ConsignmentSearchModel
|
public class ConsignmentSearchModel
|
||||||
{
|
{
|
||||||
|
public int? ID { get; set; }
|
||||||
public int? OrderID { get; set; }
|
public int? OrderID { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using ComputerStoreDataModels.Enums;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -9,6 +10,8 @@ namespace ComputerStoreContracts.SearchModels
|
|||||||
public class OrderSearchModel
|
public class OrderSearchModel
|
||||||
{
|
{
|
||||||
public int? ID { get; set; }
|
public int? ID { get; set; }
|
||||||
|
public int? ConsignmentID { get; set; }
|
||||||
|
public int? RequestID { get; set; }
|
||||||
public DateTime? DateFrom { get; set; }
|
public DateTime? DateFrom { get; set; }
|
||||||
public DateTime? DateTo { get; set; }
|
public DateTime? DateTo { get; set; }
|
||||||
public int? SellerID { get; set; }
|
public int? SellerID { get; set; }
|
||||||
|
@ -10,13 +10,11 @@ namespace ComputerStoreContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class ConsignmentViewModel : IConsignmentModel
|
public class ConsignmentViewModel : IConsignmentModel
|
||||||
{
|
{
|
||||||
|
[DisplayName("Consignment ID")]
|
||||||
|
public int ID { get; set; }
|
||||||
[DisplayName("Order ID")]
|
[DisplayName("Order ID")]
|
||||||
public int OrderID { get; }
|
public int OrderID { get; set; }
|
||||||
[DisplayName("Product ID")]
|
|
||||||
public int ProductID { get; }
|
|
||||||
[DisplayName("Price")]
|
[DisplayName("Price")]
|
||||||
public double Price { get; }
|
public double Price { get; set; }
|
||||||
[DisplayName("Count")]
|
|
||||||
public int Count { get; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,10 @@ namespace ComputerStoreContracts.ViewModels
|
|||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
[DisplayName("Price")]
|
[DisplayName("Price")]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
[DisplayName("Type of order")]
|
[DisplayName("Consignment ID")]
|
||||||
public OrderType Type { get; set; }
|
public int? ConsignmentID { get; set; }
|
||||||
|
[DisplayName("Request ID")]
|
||||||
|
public int? RequestID { get; set; }
|
||||||
[DisplayName("Status")]
|
[DisplayName("Status")]
|
||||||
public OrderStatus Status { get; set; }
|
public OrderStatus Status { get; set; }
|
||||||
[DisplayName("Creation date")]
|
[DisplayName("Creation date")]
|
||||||
|
@ -16,7 +16,5 @@ namespace ComputerStoreContracts.ViewModels
|
|||||||
public int OrderID { get; set; }
|
public int OrderID { get; set; }
|
||||||
[DisplayName("Price")]
|
[DisplayName("Price")]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
[DisplayName("Count")]
|
|
||||||
public int Count { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,13 +14,13 @@ namespace ComputerStoreContracts.ViewModels
|
|||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
[DisplayName("Username")]
|
[DisplayName("Username")]
|
||||||
public string Username { get; set; } = string.Empty;
|
public string Username { get; set; } = string.Empty;
|
||||||
[DisplayName("Password")]
|
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
[DisplayName("FirstName")]
|
[DisplayName("FirstName")]
|
||||||
public string FirstName { get; set; } = string.Empty;
|
public string? FirstName { get; set; } = string.Empty;
|
||||||
[DisplayName("LastName")]
|
[DisplayName("LastName")]
|
||||||
public string LastName { get; set; } = string.Empty;
|
public string? LastName { get; set; } = string.Empty;
|
||||||
[DisplayName("MiddleName")]
|
[DisplayName("MiddleName")]
|
||||||
public string MiddleName { get; set; } = string.Empty;
|
public string? MiddleName { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ComputerStoreDataModels.Enums
|
|
||||||
{
|
|
||||||
public enum OrderType
|
|
||||||
{
|
|
||||||
Unknown = -1,
|
|
||||||
Consigment = 0,
|
|
||||||
Request = 1
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,11 +6,9 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ComputerStoreDataModels.Models
|
namespace ComputerStoreDataModels.Models
|
||||||
{
|
{
|
||||||
public interface IConsignmentModel
|
public interface IConsignmentModel : IID
|
||||||
{
|
{
|
||||||
int OrderID { get; }
|
int OrderID { get; }
|
||||||
int ProductID { get; }
|
|
||||||
double Price { get; }
|
double Price { get; }
|
||||||
int Count { get; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,8 @@ namespace ComputerStoreDataModels.Models
|
|||||||
public interface IOrderModel : IID
|
public interface IOrderModel : IID
|
||||||
{
|
{
|
||||||
double Price { get; }
|
double Price { get; }
|
||||||
OrderType Type { get; }
|
int? ConsignmentID { get; }
|
||||||
|
int? RequestID { get; }
|
||||||
OrderStatus Status { get; }
|
OrderStatus Status { get; }
|
||||||
DateTime DateCreate { get; }
|
DateTime DateCreate { get; }
|
||||||
DateTime? DateImplement { get; }
|
DateTime? DateImplement { get; }
|
||||||
|
@ -10,6 +10,5 @@ namespace ComputerStoreDataModels.Models
|
|||||||
{
|
{
|
||||||
int OrderID { get; }
|
int OrderID { get; }
|
||||||
double Price { get; }
|
double Price { get; }
|
||||||
int Count { get; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user