Minor clean-up on Entity, Domain Events.
This commit is contained in:
parent
a88fbf339f
commit
d2f7d6a5d6
@ -178,16 +178,16 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O
|
|||||||
private void AddOrderStartedDomainEvent(string userId, int cardTypeId, string cardNumber,
|
private void AddOrderStartedDomainEvent(string userId, int cardTypeId, string cardNumber,
|
||||||
string cardSecurityNumber, string cardHolderName, DateTime cardExpiration)
|
string cardSecurityNumber, string cardHolderName, DateTime cardExpiration)
|
||||||
{
|
{
|
||||||
var orderStartedDomainEvent = new OrderStartedDomainEvent(
|
var orderStartedDomainEvent = new OrderStartedDomainEvent(this, userId, cardTypeId,
|
||||||
this, userId, cardTypeId, cardNumber, cardSecurityNumber,
|
cardNumber, cardSecurityNumber,
|
||||||
cardHolderName, cardExpiration);
|
cardHolderName, cardExpiration);
|
||||||
|
|
||||||
this.AddDomainEvent(orderStartedDomainEvent);
|
this.AddDomainEvent(orderStartedDomainEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StatusChangeException(OrderStatus orderStatusToChange)
|
private void StatusChangeException(OrderStatus orderStatusToChange)
|
||||||
{
|
{
|
||||||
throw new OrderingDomainException($"Not possible to change order status from {OrderStatus.Name} to {orderStatusToChange.Name}.");
|
throw new OrderingDomainException($"Is not possible to change the order status from {OrderStatus.Name} to {orderStatusToChange.Name}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public decimal GetTotal()
|
public decimal GetTotal()
|
||||||
|
@ -9,8 +9,7 @@ namespace Ordering.Domain.Events
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event used when an order is created
|
/// Event used when an order is created
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class OrderStartedDomainEvent
|
public class OrderStartedDomainEvent : INotification
|
||||||
: INotification
|
|
||||||
{
|
{
|
||||||
public string UserId { get; private set; }
|
public string UserId { get; private set; }
|
||||||
public int CardTypeId { get; private set; }
|
public int CardTypeId { get; private set; }
|
||||||
@ -21,9 +20,9 @@ namespace Ordering.Domain.Events
|
|||||||
public Order Order { get; private set; }
|
public Order Order { get; private set; }
|
||||||
|
|
||||||
public OrderStartedDomainEvent(Order order, string userId,
|
public OrderStartedDomainEvent(Order order, string userId,
|
||||||
int cardTypeId, string cardNumber,
|
int cardTypeId, string cardNumber,
|
||||||
string cardSecurityNumber, string cardHolderName,
|
string cardSecurityNumber, string cardHolderName,
|
||||||
DateTime cardExpiration)
|
DateTime cardExpiration)
|
||||||
{
|
{
|
||||||
Order = order;
|
Order = order;
|
||||||
UserId = userId;
|
UserId = userId;
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
private List<INotification> _domainEvents;
|
private List<INotification> _domainEvents;
|
||||||
public List<INotification> DomainEvents => _domainEvents;
|
public List<INotification> DomainEvents => _domainEvents;
|
||||||
|
|
||||||
public void AddDomainEvent(INotification eventItem)
|
public void AddDomainEvent(INotification eventItem)
|
||||||
{
|
{
|
||||||
_domainEvents = _domainEvents ?? new List<INotification>();
|
_domainEvents = _domainEvents ?? new List<INotification>();
|
||||||
|
@ -12,7 +12,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure
|
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure
|
||||||
{
|
{
|
||||||
public class OrderingContext : DbContext,IUnitOfWork
|
public class OrderingContext : DbContext, IUnitOfWork
|
||||||
{
|
{
|
||||||
public const string DEFAULT_SCHEMA = "ordering";
|
public const string DEFAULT_SCHEMA = "ordering";
|
||||||
public DbSet<Order> Orders { get; set; }
|
public DbSet<Order> Orders { get; set; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user