Skip to content

Commit 9aed822

Browse files
Work in progress for the Ordering microservice Domain Model
1 parent b6befd6 commit 9aed822

16 files changed

Lines changed: 774 additions & 7 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
6+
namespace Microsoft.eShopOnContainers.Services.Ordering.API.DTO
7+
{
8+
public class OrderDTO
9+
{
10+
}
11+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Runtime.Serialization;
3+
4+
5+
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order
6+
{
7+
[DataContract]
8+
public sealed class OrderItemDTO
9+
{
10+
public OrderItemDTO() { }
11+
12+
[DataMember]
13+
public Guid Id { get; set; }
14+
15+
[DataMember]
16+
public int Quantity { get; set; }
17+
18+
[DataMember]
19+
public int FulfillmentRemaining { get; set; }
20+
21+
public override string ToString()
22+
{
23+
return String.Format("ID: {0}, Quantity: {1}, Fulfillment Remaing: {2}", this.ItemId, this.Quantity, this.FulfillmentRemaining);
24+
}
25+
}
26+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using System;
2+
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork;
3+
4+
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel
5+
{
6+
public class Buyer : AggregateRoot
7+
{
8+
public Buyer(Guid buyerId, string name, string lastName, string email, Address address, string phoneNumber)
9+
{
10+
this.BuyerId = buyerId;
11+
this.Name = name;
12+
this.LastName = lastName;
13+
this.Email = email;
14+
this.Address = address;
15+
this.PhoneNumber = phoneNumber;
16+
}
17+
18+
protected Buyer() { } // infrastructure
19+
20+
public virtual Guid BuyerId
21+
{
22+
get;
23+
private set;
24+
}
25+
26+
public virtual string Name
27+
{
28+
get;
29+
private set;
30+
}
31+
32+
public virtual string LastName
33+
{
34+
get;
35+
private set;
36+
}
37+
38+
public virtual string Email
39+
{
40+
get;
41+
private set;
42+
}
43+
44+
public virtual Address Address
45+
{
46+
get;
47+
private set;
48+
}
49+
50+
public virtual string PhoneNumber
51+
{
52+
get;
53+
private set;
54+
}
55+
}
56+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork;
5+
6+
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel
7+
{
8+
public class Address : ValueObject<Address> //A VO doesn't have IDENTITY, like in this case, the Address
9+
{
10+
public virtual String Street
11+
{
12+
get;
13+
private set;
14+
}
15+
16+
public virtual String City
17+
{
18+
get;
19+
private set;
20+
}
21+
22+
public virtual String State
23+
{
24+
get;
25+
private set;
26+
}
27+
28+
public virtual String StateCode
29+
{
30+
get;
31+
private set;
32+
}
33+
34+
public virtual String Country
35+
{
36+
get;
37+
private set;
38+
}
39+
40+
public virtual String CountryCode
41+
{
42+
get;
43+
private set;
44+
}
45+
46+
public virtual String ZipCode
47+
{
48+
get;
49+
private set;
50+
}
51+
52+
public virtual double Latitude
53+
{
54+
get;
55+
private set;
56+
}
57+
58+
public virtual double Longitude
59+
{
60+
get;
61+
private set;
62+
}
63+
}
64+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
6+
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork;
7+
8+
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel
9+
{
10+
public class Order : AggregateRoot
11+
{
12+
public Order(Guid buyerId, Address shippingAddress, Address billingAddress)
13+
: this(buyerId, shippingAddress, billingAddress, DateTime.UtcNow)
14+
{
15+
}
16+
17+
public Order(Guid buyerId, Address shippingAddress, Address billingAddress, DateTime orderDate)
18+
{
19+
this.BuyerId = buyerId;
20+
this.ShippingAddress = shippingAddress;
21+
this.BillingAddress = billingAddress;
22+
this.OrderDate = orderDate;
23+
}
24+
25+
protected Order() { } // Infrastructure. EF might need a plain constructor. Do not use.
26+
27+
//Order ID comes derived from the Entity base class
28+
29+
List<OrderItem> _orderItems;
30+
public virtual List<OrderItem> orderItems
31+
{
32+
get
33+
{
34+
if (_orderItems == null)
35+
_orderItems = new List<OrderItem>();
36+
37+
return _orderItems;
38+
}
39+
40+
private set
41+
{
42+
_orderItems = value;
43+
}
44+
}
45+
46+
public virtual Guid BuyerId
47+
{
48+
get;
49+
private set;
50+
}
51+
52+
public virtual Address ShippingAddress
53+
{
54+
get;
55+
private set;
56+
}
57+
58+
public virtual Address BillingAddress
59+
{
60+
get;
61+
private set;
62+
}
63+
64+
public virtual DateTime OrderDate
65+
{
66+
get;
67+
private set;
68+
}
69+
70+
public virtual OrderStatus Status
71+
{
72+
get;
73+
set;
74+
}
75+
76+
}
77+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using System.Runtime.Serialization;
3+
4+
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork;
5+
6+
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel
7+
{
8+
public class OrderItem : Entity
9+
{
10+
//(CDLTLL) Might remove this constructor so
11+
// just with a method in the Order-AggregateRoot you can add an OrderItem..
12+
//public OrderItem(Guid itemId, decimal itemPrice, int quantity)
13+
//{
14+
// this.Id = itemId;
15+
// this.ItemPrice = itemPrice;
16+
// this.Quantity = quantity;
17+
// this.FulfillmentRemaining = quantity; <---- Put this logic into the AggregateRoot method AddOrderItem()
18+
//}
19+
20+
protected OrderItem() { } // Infrastructure. EF might need a plain constructor. Do not use.
21+
22+
public Guid ItemId { get; set; }
23+
24+
public decimal ItemPrice { get; set; }
25+
26+
public int Quantity { get; set; }
27+
28+
public int FulfillmentRemaining { get; set; }
29+
30+
public override string ToString()
31+
{
32+
return String.Format("ID: {0}, Quantity: {1}, Fulfillment Remaing: {2}", this.ItemId, this.Quantity, this.FulfillmentRemaining);
33+
}
34+
}
35+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
6+
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel
7+
{
8+
public enum OrderStatus
9+
{
10+
Unknown,
11+
New,
12+
Submitted,
13+
InProcess,
14+
Backordered,
15+
Shipped,
16+
Canceled,
17+
}
18+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
6+
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.RepositoryContracts
7+
{
8+
interface IBuyerRepository
9+
{
10+
}
11+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
6+
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel;
7+
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork;
8+
9+
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.RepositoryContracts
10+
{
11+
public interface IOrderRepository : IRepository<Order>
12+
{
13+
Order Get(int associatedConferenceId);
14+
15+
void ModifyOrder(Order seatOrder);
16+
}
17+
}

src/Services/Ordering/Ordering.Domain/SeedWork/AggregateRoot.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork
77
{
8-
public class AggregateRoot
8+
public class AggregateRoot : Entity
99
{
1010
}
1111
}

0 commit comments

Comments
 (0)