Skip to content

Commit

Permalink
Adding Order and OrderItem entities. related #2
Browse files Browse the repository at this point in the history
  • Loading branch information
lscoder committed Aug 17, 2011
1 parent 9cf68d5 commit 2b92238
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 0 deletions.
64 changes: 64 additions & 0 deletions src/PetStore.Core/DomainObjects/Foundation/Order.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using PetStore.Core.DomainObjects.Payment;
using PetStore.Core.DomainObjects.Security;

namespace PetStore.Core.DomainObjects.Foundation
{
/// <summary>
/// Order entity
/// </summary>
public class Order
{
#region Public Properties

/// <summary>
/// Order ID
/// </summary>
public virtual int Id { get; set; }

/// <summary>
/// Order user
/// </summary>
public virtual User User { get; set;}

/// <summary>
/// Credit card used to pay the order
/// </summary>
public virtual CreditCard CreditCard { get; set; }

/// <summary>
/// Order billing address
/// </summary>
public virtual Address BillingAddress { get; set; }

/// <summary>
/// Order shipping address
/// </summary>
public virtual Address ShippingAddress { get; set; }

/// <summary>
/// Order items
/// </summary>
public virtual IList<OrderItem> Items { get; set; }

/// <summary>
/// Order total
/// </summary>
public virtual decimal Total { get; set; }


/// <summary>
/// Credit card authorization number
/// TODO - It must be on CreditCardPayment entity
/// </summary>
public virtual int? AuthorizationNumber { get; set; }

/// <summary>
/// Order creation date
/// </summary>
public virtual DateTime CreatedAt { get; set; }

#endregion
}
}
48 changes: 48 additions & 0 deletions src/PetStore.Core/DomainObjects/Foundation/OrderItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
namespace PetStore.Core.DomainObjects.Foundation
{
/// <summary>
/// Order item entity
/// </summary>
public class OrderItem
{
#region Public Properties

/// <summary>
/// Order item ID
/// </summary>
public virtual int Id { get; set; }

/// <summary>
/// Order that contains this item
/// </summary>
public virtual Order Order { get; set; }

/// <summary>
/// Product
/// </summary>
public virtual Product Product { get; set; }

/// <summary>
/// Product quantity
/// </summary>
public virtual int Quantity { get; set; }

/// <summary>
/// Product price
/// </summary>
public virtual decimal Price { get; set; }

/// <summary>
/// Order item subtotal
/// </summary>
public virtual decimal SubTotal
{
get
{
return Quantity*Price;
}
}

#endregion
}
}
4 changes: 4 additions & 0 deletions src/PetStore.Core/PetStore.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
<Compile Include="DomainException.cs" />
<Compile Include="DomainObjects\DomainObjectsFactory.cs" />
<Compile Include="DomainObjects\Foundation\Address.cs" />
<Compile Include="DomainObjects\Foundation\OrderItem.cs" />
<Compile Include="DomainObjects\Payment\CreditCard.cs" />
<Compile Include="DomainObjects\Foundation\Order.cs" />
<Compile Include="DomainObjects\Foundation\Category.cs" />
<Compile Include="DomainObjects\Foundation\Country.cs" />
<Compile Include="DomainObjects\Foundation\Product.cs" />
Expand All @@ -54,6 +57,7 @@
<Compile Include="DomainObjects\Log\GenericError.cs" />
<Compile Include="DomainObjects\Log\Validation\ErrorValidationException.cs" />
<Compile Include="DomainObjects\Log\Validation\ErrorValidator.cs" />
<Compile Include="DomainObjects\Payment\CreditCardAssociation.cs" />
<Compile Include="DomainObjects\Security\User.cs" />
<Compile Include="DomainObjects\ValidationException.cs" />
<Compile Include="Extension\StringExtension.cs" />
Expand Down

0 comments on commit 2b92238

Please sign in to comment.