本文整理汇总了C#中IOrder.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# IOrder.GetHashCode方法的具体用法?C# IOrder.GetHashCode怎么用?C# IOrder.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOrder
的用法示例。
在下文中一共展示了IOrder.GetHashCode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PlaceOrder
/// <summary>
/// Places an order on shopster.
/// </summary>
/// <param name="apiContext"></param>
/// <param name="orderToPlace"></param>
/// <param name="productMap"></param>
/// <returns>Null if failed, Shopster NewOrderId otherwise. </returns>
public int? PlaceOrder(ApiContext apiContext, IOrder orderToPlace, Dictionary<int, int> productMap)
{
try
{
var call = new PlaceOrderCall(apiContext) {Request = new PlaceOrderRequestType()};
string messageId = orderToPlace.GetHashCode().ToString(); //This should be unique enough right?
call.Request.MessageID = messageId;
call.Request.Cart = ShopsterOrderConverter.ToShopsterOrder(orderToPlace, productMap).orderCart;
if (call.Request.Cart != null && call.Request.Cart.Items != null && call.Request.Cart.Items.Count > 0)
{
call.Execute();
if (call.Response.Status == ResponseStatusType.Failed)
{
//Todo: Fix this hack, should still return null.
//Todo: Implement email/messaging in API to send something to the user.
ApiLogger.ErrorFormat(
"ShopsterCommunicator::PlaceOrder(): Reponse.Status is 'Failed' for ShopsterAccessToken({0}), ",
apiContext.AccessToken);
return null;
}
//TODO : handle warnings
if (call.Response.Status == ResponseStatusType.Success ||
call.Response.Status == ResponseStatusType.SuccessWithWarnings)
{
if (call.Response.MessageID != messageId || call.Response.NewOrderId == null)
{
//Should never happen in syncronous environment.
ApiLogger.WarnFormat(
"ShopsterCommunicator::PlaceOrder(): Strange situation: API Call was assigned messageId({0}), but returned messageId({1}).",
messageId, call.Response.MessageID);
}
try
{
return Convert.ToInt32(call.Response.NewOrderId);
}
catch (Exception e)
{
ApiLogger.ErrorFormat(
"ShopsterCommunicator::PlaceOrder(): Couldnt convert call.Response.NewOrderId to int32. Exception is ({0})",
e.Message);
return null;
}
}
}
}
catch (ApiException ae)
{
string result = ae.Message;
if (ae is ApiFaultException)
{
var afe = (ApiFaultException) ae;
result = string.Format("({0}) {1}: {2}", afe.Error.SeverityCode, result,
afe.Error.Message);
//TODO: Logging
ApiLogger.ErrorFormat("ShopsterCommunicator::PlaceOrder(): ApiFaultException: ({0}) {1}: {2}",
afe.Error.SeverityCode, result,
afe.Error.Message);
}
return null;
}
return null;
}