Exemplo n.º 1
0
        public List <FavouriteSKUItemResponseViewModel> GetFavouriteSKUs(GetFavouriteParam request)
        {
            List <FavouriteSKUItemResponseViewModel> result = null;


            if (string.IsNullOrWhiteSpace(request.Locale) || string.IsNullOrWhiteSpace(request.DistributorID))
            {
                return(result);
            }

            try
            {
                List <FavouriteSKU> SKUs = new List <FavouriteSKU>();
                SKUs = _favorLoader.GetDistributorFavouriteSKU(request.DistributorID, request.Locale);

                if (SKUs.Count > 0)
                {
                    result = ConvertToFavouriteItemViewModel(SKUs);
                }

                return(result);
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(string.Format("MobileFavouriteSKUProvider : {0}\n {1}\n", ex.Message, ex.StackTrace));
                return(result);
            }
        }
Exemplo n.º 2
0
        public MobileResponseWrapper Get([FromUri] FavouriteSKUItemViewModel query)
        {
            try
            {
                List <FavouriteSKUItemResponseViewModel> result = null;

                if (query == null)
                {
                    throw CreateException(HttpStatusCode.BadRequest, "Invalid or Incomplete GetFavouriteSKU information", 999999);
                }
                string obj = JsonConvert.SerializeObject(query);

                query.Locale = Thread.CurrentThread.CurrentCulture.Name != null ? Thread.CurrentThread.CurrentCulture.Name : null;

                if (string.IsNullOrEmpty(query.MemberId) || string.IsNullOrEmpty(query.Locale))
                {
                    return(new MobileResponseWrapper {
                        Data = new FavouriteSKUResponseViewModel {
                            FavouriteSKUs = null, RecordCount = 0
                        }
                    });
                }

                GetFavouriteParam request = new GetFavouriteParam {
                    DistributorID = query.MemberId, Locale = query.Locale
                };

                result = _mobileFavouriteProvider.GetFavouriteSKUs(request);
                if (result != null)
                {
                    var response = new MobileResponseWrapper
                    {
                        Data =
                            new FavouriteSKUResponseViewModel
                        {
                            FavouriteSKUs = result,
                            RecordCount   = result.Count()
                        }
                    };
                    JObject json = JObject.Parse(obj);
                    MobileActivityLogProvider.ActivityLog(json, response, query.DistributorID, true,
                                                          this.Request.RequestUri.ToString(),
                                                          this.Request.Headers.ToString(),
                                                          this.Request.Headers.UserAgent.ToString(),
                                                          query.Locale);

                    return(response);
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(ex.ToString() + query.MemberId);
                throw CreateException(HttpStatusCode.InternalServerError,
                                      "Internal server errror searching for Get Favourite SKUs" + ex.Message, 404);
            }
            var responseWrapper = new MobileResponseWrapper
            {
                Data = new FavouriteSKUResponseViewModel {
                    FavouriteSKUs = null, RecordCount = 0
                }
            };

            MobileActivityLogProvider.ActivityLog(query, responseWrapper, query.MemberId, true,
                                                  this.Request.RequestUri.ToString(),
                                                  this.Request.Headers.ToString(),
                                                  this.Request.Headers.UserAgent.ToString(),
                                                  query.Locale);

            return(responseWrapper);
        }