Moved namespaces to ordering.domain project

This commit is contained in:
Sumit Ghosh 2021-10-08 17:54:02 +05:30
parent 46dad7ac75
commit 4758530f1f
23 changed files with 648 additions and 740 deletions

View File

@ -1,14 +1,8 @@
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork; namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
using Ordering.Domain.Events;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate public class Buyer
{
public class Buyer
: Entity, IAggregateRoot : Entity, IAggregateRoot
{ {
public string IdentityGuid { get; private set; } public string IdentityGuid { get; private set; }
public string Name { get; private set; } public string Name { get; private set; }
@ -51,5 +45,4 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.B
return payment; return payment;
} }
}
} }

View File

@ -1,14 +1,14 @@
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork;
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
{
/// <remarks> /// <remarks>
/// Card type class should be marked as abstract with protected constructor to encapsulate known enum types /// Card type class should be marked as abstract with protected constructor to encapsulate known enum types
/// this is currently not possible as OrderingContextSeed uses this constructor to load cardTypes from csv file /// this is currently not possible as OrderingContextSeed uses this constructor to load cardTypes from csv file
/// </remarks> /// </remarks>
public class CardType public class CardType
: Enumeration : Enumeration
{ {
public static CardType Amex = new(1, nameof(Amex)); public static CardType Amex = new(1, nameof(Amex));
public static CardType Visa = new(2, nameof(Visa)); public static CardType Visa = new(2, nameof(Visa));
public static CardType MasterCard = new(3, nameof(MasterCard)); public static CardType MasterCard = new(3, nameof(MasterCard));
@ -17,5 +17,4 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.B
: base(id, name) : base(id, name)
{ {
} }
}
} }

View File

@ -1,16 +1,13 @@
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork; namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate //This is just the RepositoryContracts or Interface defined at the Domain Layer
//as requisite for the Buyer Aggregate
public interface IBuyerRepository : IRepository<Buyer>
{ {
//This is just the RepositoryContracts or Interface defined at the Domain Layer
//as requisite for the Buyer Aggregate
public interface IBuyerRepository : IRepository<Buyer>
{
Buyer Add(Buyer buyer); Buyer Add(Buyer buyer);
Buyer Update(Buyer buyer); Buyer Update(Buyer buyer);
Task<Buyer> FindAsync(string BuyerIdentityGuid); Task<Buyer> FindAsync(string BuyerIdentityGuid);
Task<Buyer> FindByIdAsync(string id); Task<Buyer> FindByIdAsync(string id);
}
} }

View File

@ -1,12 +1,8 @@
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork; namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
using Ordering.Domain.Exceptions;
using System;
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate public class PaymentMethod
{
public class PaymentMethod
: Entity : Entity
{ {
private string _alias; private string _alias;
private string _cardNumber; private string _cardNumber;
private string _securityNumber; private string _securityNumber;
@ -42,5 +38,4 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.B
&& _cardNumber == cardNumber && _cardNumber == cardNumber
&& _expiration == expiration; && _expiration == expiration;
} }
}
} }

View File

@ -1,11 +1,9 @@
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork;
using System;
using System.Collections.Generic;
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
public class Address : ValueObject
{ {
public class Address : ValueObject
{
public String Street { get; private set; } public String Street { get; private set; }
public String City { get; private set; } public String City { get; private set; }
public String State { get; private set; } public String State { get; private set; }
@ -32,5 +30,4 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O
yield return Country; yield return Country;
yield return ZipCode; yield return ZipCode;
} }
}
} }

View File

@ -1,17 +1,13 @@
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork; namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate //This is just the RepositoryContracts or Interface defined at the Domain Layer
//as requisite for the Order Aggregate
public interface IOrderRepository : IRepository<Order>
{ {
//This is just the RepositoryContracts or Interface defined at the Domain Layer
//as requisite for the Order Aggregate
public interface IOrderRepository : IRepository<Order>
{
Order Add(Order order); Order Add(Order order);
void Update(Order order); void Update(Order order);
Task<Order> GetAsync(int orderId); Task<Order> GetAsync(int orderId);
}
} }

View File

@ -1,15 +1,10 @@
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork; using Microsoft.eShopOnContainers.Services.Ordering.Ordering.Domain.Events;
using Ordering.Domain.Events;
using Ordering.Domain.Exceptions;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
{
public class Order public class Order
: Entity, IAggregateRoot : Entity, IAggregateRoot
{ {
// DDD Patterns comment // DDD Patterns comment
// Using private fields, allowed since EF Core 1.1, is a much better encapsulation // Using private fields, allowed since EF Core 1.1, is a much better encapsulation
// aligned with DDD Aggregates and Domain Entities (Instead of properties and property collections) // aligned with DDD Aggregates and Domain Entities (Instead of properties and property collections)
@ -197,6 +192,4 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O
{ {
return _orderItems.Sum(o => o.GetUnits() * o.GetUnitPrice()); return _orderItems.Sum(o => o.GetUnits() * o.GetUnitPrice());
} }
}
} }

View File

@ -1,11 +1,8 @@
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork; namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
using Ordering.Domain.Exceptions;
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate public class OrderItem
{
public class OrderItem
: Entity : Entity
{ {
// DDD Patterns comment // DDD Patterns comment
// Using private fields, allowed since EF Core 1.1, is a much better encapsulation // Using private fields, allowed since EF Core 1.1, is a much better encapsulation
// aligned with DDD Aggregates and Domain Entities (Instead of properties and property collections) // aligned with DDD Aggregates and Domain Entities (Instead of properties and property collections)
@ -78,5 +75,4 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O
_units += units; _units += units;
} }
}
} }

View File

@ -1,14 +1,10 @@
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork;
{
using global::Ordering.Domain.Exceptions;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork;
using System;
using System.Collections.Generic;
using System.Linq;
public class OrderStatus namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
public class OrderStatus
: Enumeration : Enumeration
{ {
public static OrderStatus Submitted = new OrderStatus(1, nameof(Submitted).ToLowerInvariant()); public static OrderStatus Submitted = new OrderStatus(1, nameof(Submitted).ToLowerInvariant());
public static OrderStatus AwaitingValidation = new OrderStatus(2, nameof(AwaitingValidation).ToLowerInvariant()); public static OrderStatus AwaitingValidation = new OrderStatus(2, nameof(AwaitingValidation).ToLowerInvariant());
public static OrderStatus StockConfirmed = new OrderStatus(3, nameof(StockConfirmed).ToLowerInvariant()); public static OrderStatus StockConfirmed = new OrderStatus(3, nameof(StockConfirmed).ToLowerInvariant());
@ -48,5 +44,4 @@
return state; return state;
} }
}
} }

View File

@ -1,11 +1,8 @@
using MediatR; namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.Events;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
namespace Ordering.Domain.Events public class BuyerAndPaymentMethodVerifiedDomainEvent
{
public class BuyerAndPaymentMethodVerifiedDomainEvent
: INotification : INotification
{ {
public Buyer Buyer { get; private set; } public Buyer Buyer { get; private set; }
public PaymentMethod Payment { get; private set; } public PaymentMethod Payment { get; private set; }
public int OrderId { get; private set; } public int OrderId { get; private set; }
@ -16,5 +13,4 @@ namespace Ordering.Domain.Events
Payment = payment; Payment = payment;
OrderId = orderId; OrderId = orderId;
} }
}
} }

View File

@ -1,15 +1,12 @@
using MediatR; namespace Microsoft.eShopOnContainers.Services.Ordering.Ordering.Domain.Events;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
namespace Ordering.Domain.Events public class OrderCancelledDomainEvent : INotification
{ {
public class OrderCancelledDomainEvent : INotification
{
public Order Order { get; } public Order Order { get; }
public OrderCancelledDomainEvent(Order order) public OrderCancelledDomainEvent(Order order)
{ {
Order = order; Order = order;
} }
}
} }

View File

@ -1,15 +1,11 @@
using MediatR; namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.Events;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
namespace Ordering.Domain.Events public class OrderShippedDomainEvent : INotification
{ {
public class OrderShippedDomainEvent : INotification
{
public Order Order { get; } public Order Order { get; }
public OrderShippedDomainEvent(Order order) public OrderShippedDomainEvent(Order order)
{ {
Order = order; Order = order;
} }
}
} }

View File

@ -1,8 +1,5 @@
using MediatR; 
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate; namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.Events
using System;
namespace Ordering.Domain.Events
{ {
/// <summary> /// <summary>
/// Event used when an order is created /// Event used when an order is created

View File

@ -1,15 +1,11 @@
namespace Ordering.Domain.Events namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.Events;
{
using MediatR;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
using System.Collections.Generic;
/// <summary> /// <summary>
/// Event used when the grace period order is confirmed /// Event used when the grace period order is confirmed
/// </summary> /// </summary>
public class OrderStatusChangedToAwaitingValidationDomainEvent public class OrderStatusChangedToAwaitingValidationDomainEvent
: INotification : INotification
{ {
public int OrderId { get; } public int OrderId { get; }
public IEnumerable<OrderItem> OrderItems { get; } public IEnumerable<OrderItem> OrderItems { get; }
@ -19,5 +15,4 @@
OrderId = orderId; OrderId = orderId;
OrderItems = orderItems; OrderItems = orderItems;
} }
}
} }

View File

@ -1,15 +1,10 @@
namespace Ordering.Domain.Events namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.Events;
{ /// <summary>
using MediatR; /// Event used when the order is paid
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate; /// </summary>
using System.Collections.Generic; public class OrderStatusChangedToPaidDomainEvent
/// <summary>
/// Event used when the order is paid
/// </summary>
public class OrderStatusChangedToPaidDomainEvent
: INotification : INotification
{ {
public int OrderId { get; } public int OrderId { get; }
public IEnumerable<OrderItem> OrderItems { get; } public IEnumerable<OrderItem> OrderItems { get; }
@ -19,5 +14,4 @@
OrderId = orderId; OrderId = orderId;
OrderItems = orderItems; OrderItems = orderItems;
} }
}
} }

View File

@ -1,16 +1,13 @@
namespace Ordering.Domain.Events namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.Events;
{
using MediatR;
/// <summary> /// <summary>
/// Event used when the order stock items are confirmed /// Event used when the order stock items are confirmed
/// </summary> /// </summary>
public class OrderStatusChangedToStockConfirmedDomainEvent public class OrderStatusChangedToStockConfirmedDomainEvent
: INotification : INotification
{ {
public int OrderId { get; } public int OrderId { get; }
public OrderStatusChangedToStockConfirmedDomainEvent(int orderId) public OrderStatusChangedToStockConfirmedDomainEvent(int orderId)
=> OrderId = orderId; => OrderId = orderId;
}
} }

View File

@ -1,12 +1,10 @@
using System; namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.Exceptions;
namespace Ordering.Domain.Exceptions /// <summary>
/// Exception type for domain exceptions
/// </summary>
public class OrderingDomainException : Exception
{ {
/// <summary>
/// Exception type for domain exceptions
/// </summary>
public class OrderingDomainException : Exception
{
public OrderingDomainException() public OrderingDomainException()
{ } { }
@ -17,5 +15,4 @@ namespace Ordering.Domain.Exceptions
public OrderingDomainException(string message, Exception innerException) public OrderingDomainException(string message, Exception innerException)
: base(message, innerException) : base(message, innerException)
{ } { }
}
} }

View File

@ -1,11 +1,7 @@
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork;
{
using MediatR;
using System;
using System.Collections.Generic;
public abstract class Entity public abstract class Entity
{ {
int? _requestedHashCode; int? _requestedHashCode;
int _Id; int _Id;
public virtual int Id public virtual int Id
@ -88,5 +84,4 @@
{ {
return !(left == right); return !(left == right);
} }
}
} }

View File

@ -1,12 +1,7 @@
using System; namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork public abstract class Enumeration : IComparable
{ {
public abstract class Enumeration : IComparable
{
public string Name { get; private set; } public string Name { get; private set; }
public int Id { get; private set; } public int Id { get; private set; }
@ -66,5 +61,4 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork
} }
public int CompareTo(object other) => Id.CompareTo(((Enumeration)other).Id); public int CompareTo(object other) => Id.CompareTo(((Enumeration)other).Id);
}
} }

View File

@ -1,6 +1,5 @@
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork;
{
public interface IAggregateRoot { }
public interface IAggregateRoot { }
}

View File

@ -1,7 +1,6 @@
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork;
public interface IRepository<T> where T : IAggregateRoot
{ {
public interface IRepository<T> where T : IAggregateRoot
{
IUnitOfWork UnitOfWork { get; } IUnitOfWork UnitOfWork { get; }
}
} }

View File

@ -1,12 +1,7 @@
using System; namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork;
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork public interface IUnitOfWork : IDisposable
{ {
public interface IUnitOfWork : IDisposable
{
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default(CancellationToken)); Task<int> SaveChangesAsync(CancellationToken cancellationToken = default(CancellationToken));
Task<bool> SaveEntitiesAsync(CancellationToken cancellationToken = default(CancellationToken)); Task<bool> SaveEntitiesAsync(CancellationToken cancellationToken = default(CancellationToken));
}
} }

View File

@ -1,10 +1,7 @@
using System.Collections.Generic; namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork;
using System.Linq;
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork public abstract class ValueObject
{ {
public abstract class ValueObject
{
protected static bool EqualOperator(ValueObject left, ValueObject right) protected static bool EqualOperator(ValueObject left, ValueObject right)
{ {
if (ReferenceEquals(left, null) ^ ReferenceEquals(right, null)) if (ReferenceEquals(left, null) ^ ReferenceEquals(right, null))
@ -44,5 +41,4 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork
{ {
return this.MemberwiseClone() as ValueObject; return this.MemberwiseClone() as ValueObject;
} }
}
} }