public virtual IList <ShippingMethod> GetAllShippingMethods(GetShippingOptionRequest request = null, int storeId = 0) { var query = from sm in _shippingMethodRepository.Table select sm; if (!QuerySettings.IgnoreMultiStore && storeId > 0) { query = from x in query join sm in _storeMappingRepository.TableUntracked on new { c1 = x.Id, c2 = "ShippingMethod" } equals new { c1 = sm.EntityId, c2 = sm.EntityName } into x_sm from sm in x_sm.DefaultIfEmpty() where !x.LimitedToStores || storeId == sm.StoreId select x; query = from x in query group x by x.Id into grp orderby grp.Key select grp.FirstOrDefault(); } var allMethods = query.OrderBy(x => x.DisplayOrder).ToList(); if (request == null) { return(allMethods); } IList <IShippingMethodFilter> allFilters = null; var filterRequest = new ShippingFilterRequest { Option = request }; var activeShippingMethods = allMethods.Where(s => { // Shipping method filtering. if (allFilters == null) { allFilters = GetAllShippingMethodFilters(); } filterRequest.ShippingMethod = s; if (allFilters.Any(x => x.IsExcluded(filterRequest))) { return(false); } return(true); }); return(activeShippingMethods.ToList()); }
public virtual IList <ShippingMethod> GetAllShippingMethods(GetShippingOptionRequest request = null) { var query = from sm in _shippingMethodRepository.Table orderby sm.DisplayOrder select sm; var allMethods = query.ToList(); if (request == null) { return(allMethods); } IList <IShippingMethodFilter> allFilters = null; var filterRequest = new ShippingFilterRequest { Option = request }; var activeShippingMethods = allMethods.Where(s => { // shipping method filtering if (allFilters == null) { allFilters = GetAllShippingMethodFilters(); } filterRequest.ShippingMethod = s; if (allFilters.Any(x => x.IsExcluded(filterRequest))) { return(false); } return(true); }); return(activeShippingMethods.ToList()); }