Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Bitpapr.Washee.Domain
- {
- public class TreatmentOrder : Entity<Guid>
- {
- public DateTime DeliveryDate { get; protected set; }
- public DateTime CreationDate { get; protected set; }
- public decimal TotalPrice { get; protected set; }
- public ICollection<TreatmentOrderLine> OrderLines { get; protected set; }
- public Customer Customer { get; private set; }
- public Employee Employee { get; private set; }
- public TreatmentOrder(Guid id) :
- base(id)
- {
- OrderLines = new List<TreatmentOrderLine>();
- }
- protected TreatmentOrder() :
- base(Guid.NewGuid())
- {
- }
- public void AddOrderLine(TreatmentOrderLine orderLine)
- {
- TotalPrice += orderLine.TreatmentPrice;
- OrderLines.Add(orderLine);
- }
- public void UpdateDeliveryDate(DateTime newDeliveryDate)
- {
- DeliveryDate = newDeliveryDate;
- }
- public static TreatmentOrder CreateOrder(Guid id, Customer customer, Employee employee,
- DateTime creationDate, DateTime deliveryDate)
- {
- if (deliveryDate < creationDate)
- throw new InvalidOperationException();
- TreatmentOrder order = new TreatmentOrder(id);
- order.Customer = customer;
- order.Employee = employee;
- order.CreationDate = creationDate;
- order.DeliveryDate = deliveryDate;
- return order;
- }
- }
- public class TreatmentOrderLine : Entity<long>
- {
- public PieceOfClothing PieceOfClothing { get; protected set; }
- public ClothingType ClothingType { get; protected set; }
- public TreatmentType TreatmentType { get; protected set; }
- public decimal TreatmentPrice { get; protected set; }
- public TreatmentOrderLine(long id, PieceOfClothing pieceOfClothing, ClothingType clothingType,
- TreatmentType treatmentType, decimal treatmentPrice)
- : base(id)
- {
- if (treatmentPrice < 0)
- throw new ArgumentOutOfRangeException(nameof(treatmentPrice));
- PieceOfClothing = pieceOfClothing;
- ClothingType = clothingType;
- TreatmentType = treatmentType;
- TreatmentPrice = treatmentPrice;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement