|
using System;
using Iesi.Collections.Generic;
namespace ECommerceSystem.Domain
{
public class PaymentApprovedOrder
{
public PaymentApprovedOrder()
{
PaidOrderItems = new HashedSet<Item>();
}
public PaymentApprovedOrder(Order order,Payment pay)
{
PaidOrderItems = new HashedSet<Item>();
CurrentOrder = order;
// SET ONE END OF ASSOCIATION
OrderPayment = pay;
// SET OTHER END OF ASSOCIATION
pay.PaidOrder = this;
foreach (Item item in order.OrderItems)
{
//ORDER ITEMS FLAGGED HERE TO SHOW PAYMENT IS COMPLETE
//UPDATES TO DB AUTOGENERATED BY Nhibernate
if (item.IsOrdered == false)
item.IsOrdered = true;
//SET THE ORDER ITEMS
// THE ORDER USED IN PAYMENTAPPROVEDORDER HERE
//CONTAINS ORDERITEMS
AddPaidItem(item);
}
// Set the Customer BIDEIRECTIONAL ASSOCIATION
order.OrderedByCustomer.AddPaidOrder(this);
}
public virtual long PaymentApprovedOrderId { get; set; }
public virtual Order CurrentOrder { get; set; }
// NOTE: BIDIRECTIONAL ASSOCIATION WITH "PAYMENT"
public virtual Payment OrderPayment { get; set; }
//NOTE: BIDIRECTIONAL ONE-TO-MANY ASSOCIATION WITH ITEM
public virtual ISet<Item> PaidOrderItems { get; set; }
//NOTE: BIDIRECTIONAL MANY-TO-ONE ASSOCIATION WITH CUSTOMER
public virtual Customer PaidByCustomer { get; set;}
public virtual void AddPaidItem(Item item)
{
//SET THE REFERENCE FOR PAYMENTAPPROVEDORDER
//IN ITEM OBJECT TO THIS (THE PAYMENT APPROVED
//ORDER INSTANCE TO WHICH THE item IS ADDED")
// THIS IS FIRST END OF THE
// ONE-TO-MANY ASSOCIATION - THE "ONE" END
item.PaidOrder = this;
//ADD "item" TO THE SET PaidOrderItems
//OTHER END OF ASSOCIATION - THE "MANY" END
PaidOrderItems.Add(item);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.