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;
using Ordering.Domain.Events;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate
{
public class Buyer
public class Buyer
: Entity, IAggregateRoot
{
{
public string IdentityGuid { get; private set; }
public string Name { get; private set; }
@ -51,5 +45,4 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.B
return payment;
}
}
}

View File

@ -1,14 +1,14 @@
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork;
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate
{
/// <remarks>
/// 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
/// </remarks>
public class CardType
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
/// <remarks>
/// 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
/// </remarks>
public class CardType
: Enumeration
{
{
public static CardType Amex = new(1, nameof(Amex));
public static CardType Visa = new(2, nameof(Visa));
public static CardType MasterCard = new(3, nameof(MasterCard));
@ -17,5 +17,4 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.B
: base(id, name)
{
}
}
}

View File

@ -1,16 +1,13 @@
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
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 Update(Buyer buyer);
Task<Buyer> FindAsync(string BuyerIdentityGuid);
Task<Buyer> FindByIdAsync(string id);
}
}

View File

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

View File

@ -1,11 +1,9 @@
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 City { 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 ZipCode;
}
}
}

View File

@ -1,17 +1,13 @@
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
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);
void Update(Order order);
Task<Order> GetAsync(int orderId);
}
}

View File

@ -1,15 +1,10 @@
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork;
using Ordering.Domain.Events;
using Ordering.Domain.Exceptions;
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.eShopOnContainers.Services.Ordering.Ordering.Domain.Events;
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate
{
public class Order
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
public class Order
: Entity, IAggregateRoot
{
{
// DDD Patterns comment
// 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)
@ -197,6 +192,4 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O
{
return _orderItems.Sum(o => o.GetUnits() * o.GetUnitPrice());
}
}
}

View File

@ -1,11 +1,8 @@
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork;
using Ordering.Domain.Exceptions;
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate
{
public class OrderItem
public class OrderItem
: Entity
{
{
// DDD Patterns comment
// 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)
@ -78,5 +75,4 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O
_units += units;
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -1,8 +1,5 @@
using MediatR;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
using System;
namespace Ordering.Domain.Events

namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.Events
{
/// <summary>
/// Event used when an order is created

View File

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

View File

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

View File

@ -1,16 +1,13 @@
namespace Ordering.Domain.Events
{
using MediatR;
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.Events;
/// <summary>
/// Event used when the order stock items are confirmed
/// </summary>
public class OrderStatusChangedToStockConfirmedDomainEvent
/// <summary>
/// Event used when the order stock items are confirmed
/// </summary>
public class OrderStatusChangedToStockConfirmedDomainEvent
: INotification
{
{
public int OrderId { get; }
public OrderStatusChangedToStockConfirmedDomainEvent(int 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()
{ }
@ -17,5 +15,4 @@ namespace Ordering.Domain.Exceptions
public OrderingDomainException(string message, Exception innerException)
: base(message, innerException)
{ }
}
}

View File

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

View File

@ -1,12 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork;
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork
public abstract class Enumeration : IComparable
{
public abstract class Enumeration : IComparable
{
public string Name { 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);
}
}

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; }
}
}

View File

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

View File

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