2016-11-21 12:41:36 +01:00
|
|
|
|
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain
|
|
|
|
|
{
|
|
|
|
|
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
public class Order
|
2016-11-24 14:59:25 +01:00
|
|
|
|
: Entity, IAggregateRoot
|
2016-11-21 12:41:36 +01:00
|
|
|
|
{
|
|
|
|
|
public int BuyerId { get; private set; }
|
|
|
|
|
|
|
|
|
|
public Buyer Buyer { get; private set; }
|
|
|
|
|
|
|
|
|
|
public DateTime OrderDate { get; private set; }
|
|
|
|
|
|
2016-11-22 18:40:47 +01:00
|
|
|
|
public int StatusId { get; private set; }
|
|
|
|
|
|
2016-11-21 12:41:36 +01:00
|
|
|
|
public OrderStatus Status { get; private set; }
|
|
|
|
|
|
|
|
|
|
public ICollection<OrderItem> OrderItems { get; set; }
|
|
|
|
|
|
2016-11-22 18:40:47 +01:00
|
|
|
|
public int? ShippingAddressId { get; private set; }
|
2016-11-21 12:41:36 +01:00
|
|
|
|
|
|
|
|
|
public Address ShippingAddress { get; private set; }
|
|
|
|
|
|
2016-11-22 18:40:47 +01:00
|
|
|
|
public int PaymentId { get; private set; }
|
|
|
|
|
|
|
|
|
|
public Payment Payment { get; private set; }
|
|
|
|
|
|
2016-11-21 12:41:36 +01:00
|
|
|
|
protected Order() { }
|
2016-11-24 14:59:25 +01:00
|
|
|
|
|
|
|
|
|
public Order(int buyerId, int paymentId)
|
|
|
|
|
{
|
|
|
|
|
BuyerId = buyerId;
|
|
|
|
|
PaymentId = paymentId;
|
|
|
|
|
StatusId = OrderStatus.InProcess.Id;
|
|
|
|
|
OrderDate = DateTime.UtcNow;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetAddress(Address address)
|
|
|
|
|
{
|
|
|
|
|
if (address == null)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentNullException(nameof(address));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ShippingAddress = address;
|
|
|
|
|
}
|
2016-11-21 12:41:36 +01:00
|
|
|
|
}
|
|
|
|
|
}
|