本文整理汇总了C#中Transaction.EnsureEntityValidForStorage方法的典型用法代码示例。如果您正苦于以下问题:C# Transaction.EnsureEntityValidForStorage方法的具体用法?C# Transaction.EnsureEntityValidForStorage怎么用?C# Transaction.EnsureEntityValidForStorage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transaction
的用法示例。
在下文中一共展示了Transaction.EnsureEntityValidForStorage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddOrUpdateTransaction
/// <summary>
/// Adds new transaction to table storage or updates an existing item.
/// Throws exception when item is not valid, resolving customer external ID failed or if table storage operation fails.
/// </summary>
/// <param name="t">Transaction item to add/update</param>
public void AddOrUpdateTransaction(Transaction t)
{
EnsureTransactionHasCustomerInternalID(t);
t.EnsureEntityValidForStorage();
var ent = new TransactionTableEntity(t.ID.Value, t.Date.Value, t.InternalRef.Value)
{
MvaNumber = t.MvaNumber,
Amount = t.Amount,
Description = t.Description,
CustomerNumber = t.CustomerNumber,
AccountID = t.AccountID,
ProductID = t.ProductID,
NotInvoiceable = t.NotInvoiceable,
ExternalRecordID = t.ExternalRecordID,
};
AddOrUpdateTransaction(ent);
}
示例2: AddToIndex
/// <summary>
/// Adds the transaction item to search index. Can also be used for updating existing items by specifying the Transaction.ID value.
/// Throws exception when item is not valid, resolving customer external ID failed or if search index operation fails.
/// </summary>
/// <param name="t"></param>
public void AddToIndex(Transaction t)
{
t.EnsureEntityValidForStorage();
Guid internalID;
if (t.InternalRef.HasValue)
{
internalID = t.InternalRef.Value;
}
else
{
Customer c = new CustomerRepository().GetCustomerByExternalID(t.MvaNumber.Value, t.ExternalRef);
if (c == null)
{
throw new Exception(string.Format("Failed to resolve customer external ID ({0}) to internal", t.ExternalRef));
}
internalID = c.InternalID.Value;
}
var tableEnt = new TransactionTableEntity(t.ID.Value, t.Date.Value, internalID)
{
Amount = t.Amount,
CustomerNumber = t.CustomerNumber,
AccountID = t.AccountID,
Description = t.Description,
MvaNumber = t.MvaNumber,
ProductID = t.ProductID
};
AddToIndex(tableEnt);
}
示例3: AddTransactionToUpdateQueue
/// <summary>
/// Adds the transaction item to WebJob queues. Workers process each queue item and add them to transaction table and search index.
/// Can also be used for updating existing items if Transaction.ID is specified.
/// Also generates ID if it's null and sets Date to DateTime.Now if it isn't set.
/// </summary>
/// <param name="t">Transaction item to add/update</param>
/// <returns>The item that was added to queue. Throws exception when item is not valid or if adding to queue failed.</returns>
public Transaction AddTransactionToUpdateQueue(Transaction t)
{
t.EnsureEntityValidForStorage(true);
SerializeTransactionAndAddToQueue(t);
return t;
}