public MobileResponseWrapper Put(OrderRequestViewModel request)
        {
            if (request == null)
            {
                throw CreateException(HttpStatusCode.BadRequest, "request is null", 166767);
            }
            string obj = JsonConvert.SerializeObject(request);

            SetOrderMemberId(request.Data);
            request.Data.Locale = Thread.CurrentThread.CurrentCulture.Name;
            var orderNumber      = string.Empty;
            var isOrderSubmitted = false;

            if (_mobileQuoteHelper.CheckIfAnyOrderInProcessing(request.Data.MemberId, request.Data.Locale, ref orderNumber, ref isOrderSubmitted, request.Data.OrderNumber))
            {
                throw CreateException(HttpStatusCode.NotAcceptable,
                                      "order still processing", 110406, orderNumber);
            }

            //If SR Pricing an order for PC then check whether the PC is expired or not.
            if (request.Data.Locale == "zh-CN" && !string.IsNullOrEmpty(request.Data.CustomerId) && request.Data.CustomerId != request.Data.MemberId && _mobileQuoteHelper.IsPCExpired(request))
            {
                throw CreateException(HttpStatusCode.NotAcceptable,
                                      "PC membership is expired", 110421);
            }

            List <ValidationErrorViewModel> errors = null;
            var data = _iMobileQuoteProvider.Quote(request.Data, ref errors);
            var mobileResponseWrapper = new MobileResponseWrapper
            {
                Data             = data,
                ValidationErrors = null != errors && errors.Any() ? errors : null
            };
            JObject json = JObject.Parse(obj);

            MobileActivityLogProvider.ActivityLog(json, mobileResponseWrapper, request.Data.MemberId, true,
                                                  this.Request.RequestUri.ToString(),
                                                  this.Request.Headers.ToString(),
                                                  this.Request.Headers.UserAgent.ToString(),
                                                  request.Data.Locale);

            return(mobileResponseWrapper);
        }
        public OrderResponseViewModel Put(OrderRequestViewModel request)
        {
            if (request == null || request.Data.OrderItems == null)
            {
                throw CreateException(HttpStatusCode.BadRequest, "Invalid or Incomplete Order information", 101416);
            }
            string obj = JsonConvert.SerializeObject(request);

            SetOrderMemberId(request.Data);
            request.Data.Locale = Thread.CurrentThread.CurrentCulture.Name;

            //Logging the bare request before it gets modified as it is a reference type
            //MobileActivityLogProvider.ActivityLog(request, null, request.Data.MemberId, true,
            //            this.Request.RequestUri.ToString(),
            //            this.Request.Headers.ToString(),
            //            this.Request.Headers.UserAgent.ToString(),
            //            request.Data.Locale);


            var orderNumber      = string.Empty;
            var isOrderSubmitted = false;

            if (_mobileQuoteHelper.CheckIfAnyOrderInProcessing(request.Data.MemberId, request.Data.Locale,
                                                               ref orderNumber, ref isOrderSubmitted, request.Data.OrderNumber))
            {
                throw CreateException(HttpStatusCode.NotAcceptable,
                                      "order still processing", 110406, orderNumber);
            }

            var authToken = Guid.Empty;

            if (null != Request && null != Request.Headers && Request.Headers.Any())
            {
                if (Request.Headers.Contains("X-HLUSER-TOKEN"))
                {
                    var authTokenValue = Request.Headers.GetValues("X-HLUSER-TOKEN").FirstOrDefault();
                    if (!string.IsNullOrEmpty(authTokenValue))
                    {
                        Guid.TryParse(authTokenValue, out authToken);
                    }
                }
            }

            var response = new OrderResponseViewModel();
            List <ValidationErrorViewModel> errors = null;
            var result = _iMobileOrderProvider.Submit(request.Data, ref errors, authToken, request.Data.MemberId);

            if (result != null)
            {
                response.Data             = result;
                response.ValidationErrors = null != errors && errors.Any() ? errors : null;
                JObject json = JObject.Parse(obj);
                MobileActivityLogProvider.ActivityLog(json, response, request.Data.MemberId, true,
                                                      this.Request.RequestUri.ToString(),
                                                      this.Request.Headers.ToString(),
                                                      this.Request.Headers.UserAgent.ToString(),
                                                      request.Data.Locale);

                return(response);
            }

            return(new OrderResponseViewModel {
                Data = null
            });
        }