LabWork№1 #6
@ -14,34 +14,22 @@ public class Order
|
||||
public DateTime DateIssue { get; private set; }
|
||||
public int FullPrice { get; private set; }
|
||||
public int MasterId { get; private set; }
|
||||
public List<OrderDetail> OrderDetails { get; private set; }
|
||||
public IEnumerable<OrderDetail> OrderDetails { get; private set; } = [];
|
||||
|
||||
private Order()
|
||||
public static Order CreateOperation(int id, int fullPrice, int masterId, DateTime dateCompletion,
|
||||
DateTime dateIssue, IEnumerable<OrderDetail> orderDetails)
|
||||
{
|
||||
OrderDetails = new List<OrderDetail>();
|
||||
}
|
||||
|
||||
public static Order CreateOperation(int id, int fullPrice, int masterId, DateTime dateCompletion, DateTime dateIssue)
|
||||
{
|
||||
if (dateCompletion > DateTime.Now || dateIssue > DateTime.Now)
|
||||
{
|
||||
throw new ArgumentException("Дата начала работы и дата завершения не могут быть в будущем.");
|
||||
}
|
||||
|
||||
return new Order
|
||||
{
|
||||
Id = id,
|
||||
OrderDate = DateTime.Now, // Автоматически задается текущая дата
|
||||
OrderDate = DateTime.Now,
|
||||
DateCompletion = dateCompletion,
|
||||
DateIssue = dateIssue,
|
||||
FullPrice = fullPrice,
|
||||
MasterId = masterId
|
||||
MasterId = masterId,
|
||||
OrderDetails = orderDetails
|
||||
};
|
||||
}
|
||||
|
||||
public void AddOrderDetail(int detailId, int detailPrice, int detailCount)
|
||||
{
|
||||
var orderDetail = OrderDetail.CreateOperation(this.Id, detailId, detailPrice, detailCount);
|
||||
OrderDetails.Add(orderDetail);
|
||||
}
|
||||
}
|
||||
|
@ -10,16 +10,14 @@ public class OrderDetail
|
||||
{
|
||||
public int OrderId { get; private set; }
|
||||
public int DetailId { get; private set; }
|
||||
public int DetailPrice { get; private set; }
|
||||
public int DetailCount { get; private set; }
|
||||
public int DetailCount { get; private set; }
|
||||
|
||||
public static OrderDetail CreateOperation(int orderId, int detailId, int detailPrice, int detailCount)
|
||||
public static OrderDetail CreateOperation(int orderId, int detailId, int detailCount)
|
||||
{
|
||||
return new OrderDetail
|
||||
{
|
||||
OrderId = orderId,
|
||||
DetailId = detailId,
|
||||
DetailPrice = detailPrice,
|
||||
DetailCount = detailCount
|
||||
};
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ public class StorageDetail
|
||||
{
|
||||
public int StorageId { get; private set; }
|
||||
public int DetailId { get; private set; }
|
||||
public int DetailCount { get; private set; }
|
||||
public int DetailCount { get; private set; }
|
||||
public DateTime SupplyDate { get; private set; } // Дата поступления деталей
|
||||
|
||||
public static StorageDetail CreateOperation(int storageId, int detailId, int detailCount, DateTime supplyDate)
|
||||
|
@ -20,7 +20,7 @@ public class OrderRepository : IOrderRepository
|
||||
|
||||
public Order ReadOrderById(int id)
|
||||
{
|
||||
return Order.CreateOperation(0, 0, 0, DateTime.MinValue, DateTime.MinValue);
|
||||
return Order.CreateOperation(0, 0, 0, DateTime.MinValue, DateTime.MinValue, Enumerable.Empty<OrderDetail>());
|
||||
}
|
||||
|
||||
public IEnumerable<Order> ReadOrders()
|
||||
|
Loading…
x
Reference in New Issue
Block a user