当前位置: 首页>>代码示例>>C#>>正文


C# IOrder.GetHashCode方法代码示例

本文整理汇总了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;
        }
开发者ID:shopster,项目名称:NconnectSter,代码行数:75,代码来源:ShopsterCommunicator.cs


注:本文中的IOrder.GetHashCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。