Пример #1
0
        public virtual async Task <IHttpActionResult> GetStores(StoresRequest request)
        {
            var vm = await StoreLocatorViewService.GetStoreLocatorViewModelAsync(new GetStoreLocatorViewModelParam
            {
                Scope          = ComposerContext.Scope,
                CultureInfo    = ComposerContext.CultureInfo,
                BaseUrl        = RequestUtils.GetBaseUrl(Request).ToString(),
                PageNumber     = request.Page,
                PageSize       = request.PageSize > 0 ? request.PageSize : StoreConfiguration.StoreLocatorMaxItemsPerPage,
                MapBounds      = request.MapBounds,
                SearchPoint    = request.SearchPoint,
                IncludeMarkers = false
            }).ConfigureAwait(false);

            return(Ok(vm));
        }
        public virtual ActionResult Index(int pagesize = 9)
        {
            var model = StoreLocatorViewService.GetEmptyStoreLocatorViewModel(new GetEmptyStoreLocatorViewModelParam
            {
                CultureInfo = ComposerContext.CultureInfo,
                BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString(),
            });

            model.Context.Add("pageSize", pagesize);

            if (!string.IsNullOrWhiteSpace(Request["storeDirectorySearchInput"]))
            {
                model.PostedAddress = Request["storeDirectorySearchInput"];
            }
            return(View("StoreLocator", model));
        }
Пример #3
0
        public virtual async Task <IHttpActionResult> GetMarkers(MarkersRequest request)
        {
            var vm = await StoreLocatorViewService.GetStoreLocatorViewModelAsync(new GetStoreLocatorViewModelParam
            {
                Scope          = ComposerContext.Scope,
                CultureInfo    = ComposerContext.CultureInfo,
                BaseUrl        = RequestUtils.GetBaseUrl(Request).ToString(),
                PageNumber     = 1,
                PageSize       = request.PageSize > 0 ? request.PageSize : StoreConfiguration.StoreLocatorMaxItemsPerPage,
                MapBounds      = request.MapBounds,
                ZoomLevel      = request.ZoomLevel,
                SearchPoint    = request.SearchPoint,
                IncludeMarkers = true
            }).ConfigureAwait(false);

            if (request.IsSearch && (vm.Markers == null || !vm.Markers.Any()) && vm.NearestStoreCoordinate != null)
            {
                // if no markers in requested search bounds, return the coordinates of the nearest store, so always see one store on the map
                return(Ok(vm.NearestStoreCoordinate.GetCoordinate()));
            }

            return(Ok(vm));
        }