2010-03-02 17:56:21 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.Contracts
|
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
public enum BillItemType
|
|
|
|
|
{
|
2016-04-11 07:01:52 +00:00
|
|
|
|
RegularProduct,
|
|
|
|
|
HappyHourProduct,
|
2014-11-02 08:03:31 +00:00
|
|
|
|
Kot
|
2011-06-23 12:47:48 +00:00
|
|
|
|
}
|
2010-03-02 17:56:21 +00:00
|
|
|
|
public class BillItemKey
|
|
|
|
|
{
|
2014-10-12 09:41:45 +00:00
|
|
|
|
private BillItemKey(Guid productID, Guid kotID, BillItemType billItemType)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
BillItemType = billItemType;
|
|
|
|
|
ProductID = productID;
|
|
|
|
|
KotID = kotID;
|
|
|
|
|
}
|
2014-10-12 09:41:45 +00:00
|
|
|
|
public BillItemKey(Guid kotID)
|
|
|
|
|
: this(Guid.Empty, kotID, BillItemType.Kot)
|
2011-06-23 12:47:48 +00:00
|
|
|
|
{ }
|
2016-04-11 07:01:52 +00:00
|
|
|
|
public BillItemKey(Guid productID, Guid kotID, bool IsHappyHour)
|
|
|
|
|
: this(productID, kotID, IsHappyHour? BillItemType.HappyHourProduct : BillItemType.RegularProduct)
|
2011-06-23 12:47:48 +00:00
|
|
|
|
{ }
|
|
|
|
|
|
2014-10-12 09:41:45 +00:00
|
|
|
|
private Guid _productID;
|
|
|
|
|
public Guid ProductID
|
2011-06-23 12:47:48 +00:00
|
|
|
|
{
|
2016-04-11 07:01:52 +00:00
|
|
|
|
get { return BillItemType != BillItemType.Kot ? _productID : Guid.Empty; }
|
|
|
|
|
private set { _productID = BillItemType != BillItemType.Kot ? value : Guid.Empty; }
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-10-12 09:41:45 +00:00
|
|
|
|
public Guid KotID { get; private set; }
|
2011-02-18 16:54:48 +00:00
|
|
|
|
|
2011-06-23 12:47:48 +00:00
|
|
|
|
public BillItemType BillItemType { get; private set; }
|
2014-11-02 08:03:31 +00:00
|
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
{
|
2016-04-11 07:01:52 +00:00
|
|
|
|
return BillItemType.GetHashCode() ^ KotID.GetHashCode() ^ ProductID.GetHashCode() ^ BillItemType.GetHashCode();
|
2014-11-02 08:03:31 +00:00
|
|
|
|
}
|
|
|
|
|
public static bool operator ==(BillItemKey a, BillItemKey b)
|
|
|
|
|
{
|
|
|
|
|
if (object.ReferenceEquals(null, a))
|
|
|
|
|
return object.ReferenceEquals(null, b);
|
|
|
|
|
|
|
|
|
|
if (!(a is BillItemKey))
|
|
|
|
|
return false;
|
|
|
|
|
if (!(b is BillItemKey))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (a.BillItemType != b.BillItemType)
|
|
|
|
|
return false;
|
|
|
|
|
|
2016-04-11 07:01:52 +00:00
|
|
|
|
return a.KotID == b.KotID && a.BillItemType == b.BillItemType && a.ProductID == b.ProductID && a.BillItemType == b.BillItemType;
|
2014-11-02 08:03:31 +00:00
|
|
|
|
}
|
|
|
|
|
public static bool operator !=(BillItemKey a, BillItemKey b)
|
|
|
|
|
{
|
|
|
|
|
return !(a == b);
|
|
|
|
|
}
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
|
{
|
|
|
|
|
if (obj is BillItemKey)
|
|
|
|
|
return (this == (BillItemKey)obj);
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-11-02 08:03:31 +00:00
|
|
|
|
|
|
|
|
|
|