Advertisement
Henry-Keys

Untitled

Oct 3rd, 2017
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.39 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Bitpapr.Washee.Domain
  4. {
  5.     public class TreatmentOrder : Entity<Guid>
  6.     {
  7.         public DateTime DeliveryDate { get; protected set; }
  8.         public DateTime CreationDate { get; protected set; }
  9.         public decimal TotalPrice { get; protected set; }
  10.         public ICollection<TreatmentOrderLine> OrderLines { get; protected set; }
  11.         public Customer Customer { get; private set; }
  12.         public Employee Employee { get; private set; }
  13.  
  14.         public TreatmentOrder(Guid id) :
  15.             base(id)
  16.         {
  17.             OrderLines = new List<TreatmentOrderLine>();
  18.         }
  19.  
  20.         protected TreatmentOrder() :
  21.             base(Guid.NewGuid())
  22.         {
  23.         }
  24.  
  25.         public void AddOrderLine(TreatmentOrderLine orderLine)
  26.         {
  27.             TotalPrice += orderLine.TreatmentPrice;
  28.             OrderLines.Add(orderLine);
  29.         }
  30.  
  31.         public void UpdateDeliveryDate(DateTime newDeliveryDate)
  32.         {
  33.             DeliveryDate = newDeliveryDate;
  34.         }
  35.  
  36.         public static TreatmentOrder CreateOrder(Guid id, Customer customer, Employee employee,
  37.             DateTime creationDate, DateTime deliveryDate)
  38.         {
  39.             if (deliveryDate < creationDate)
  40.                 throw new InvalidOperationException();
  41.  
  42.             TreatmentOrder order = new TreatmentOrder(id);
  43.             order.Customer = customer;
  44.             order.Employee = employee;
  45.             order.CreationDate = creationDate;
  46.             order.DeliveryDate = deliveryDate;
  47.  
  48.             return order;
  49.         }
  50.     }
  51.  
  52.     public class TreatmentOrderLine : Entity<long>
  53.     {
  54.         public PieceOfClothing PieceOfClothing { get; protected set; }
  55.         public ClothingType ClothingType { get; protected set; }
  56.         public TreatmentType TreatmentType { get; protected set; }
  57.         public decimal TreatmentPrice { get; protected set; }
  58.  
  59.         public TreatmentOrderLine(long id, PieceOfClothing pieceOfClothing, ClothingType clothingType,
  60.             TreatmentType treatmentType, decimal treatmentPrice)
  61.             : base(id)
  62.         {
  63.             if (treatmentPrice < 0)
  64.                 throw new ArgumentOutOfRangeException(nameof(treatmentPrice));
  65.  
  66.             PieceOfClothing = pieceOfClothing;
  67.             ClothingType = clothingType;
  68.             TreatmentType = treatmentType;
  69.             TreatmentPrice = treatmentPrice;
  70.         }
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement