public List <AddressViewModel> Get(GetAddressRequestViewModel request) { var shippingProvider = ShippingProvider.GetShippingProvider(request.Locale.Substring(3)); var result = new List <AddressViewModel>(); if (shippingProvider != null) { var shippingAddresses = shippingProvider.GetShippingAddresses(request.MemberId, request.Locale); //filter the addresses if (request.From != null) { shippingAddresses = shippingAddresses.Where(x => x.Created >= request.From).ToList(); } if (request.To != null) { shippingAddresses = shippingAddresses.Where(x => x.Created <= request.To).ToList(); } if (shippingAddresses != null && shippingAddresses.Any()) { result.AddRange( shippingAddresses.Select( a => ModelConverter.ConvertAddressToViewModel(a, false, request.MemberId, request.Locale))); } } return(result); }
public MobileResponseWrapper Get([FromUri] GetAddressRequestViewModel request) { try { string obj = JsonConvert.SerializeObject(request); request.Locale = Thread.CurrentThread.CurrentCulture.Name; if (request == null || request.MemberId == null || string.IsNullOrEmpty(request.MemberId) || string.IsNullOrWhiteSpace(request.MemberId) || request.Locale == null || string.IsNullOrEmpty(request.Locale) || string.IsNullOrWhiteSpace(request.Locale)) { throw CreateException(HttpStatusCode.BadRequest, "Get Addresses incomplete/invalid information sended", 210416); } var result = _iMobileAddressProvider.Get(request); if (result != null) { var response = new MobileResponseWrapper { Data = new AddressListResponseViewModel { Address = result }, }; JObject json = JObject.Parse(obj); MobileActivityLogProvider.ActivityLog(json, response, request.MemberId, true, this.Request.RequestUri.ToString(), this.Request.Headers.ToString(), this.Request.Headers.UserAgent.ToString(), request.Locale); return(response); } } catch (Exception ex) { LoggerHelper.Error(ex.ToString()); throw CreateException(HttpStatusCode.InternalServerError, "Internal server errror searching for Get Address" + ex.Message, 166767); } throw CreateException(HttpStatusCode.InternalServerError, "Internal server errror searching for Get Address", 210416); }