Пример #1
0
        public virtual ActionResult List(DataSourceRequest command, DestinationListModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageDestinations))
            {
                return(AccessDeniedKendoGridJson());
            }

            var destinations = _destinationService.GetAllDestinations(model.SearchDestinationName,
                                                                      model.SearchStoreId, command.Page - 1, command.PageSize, true);
            var gridModel = new DataSourceResult
            {
                Data  = destinations.Select(x => x.ToModel()),
                Total = destinations.TotalCount
            };

            return(Json(gridModel));
        }
Пример #2
0
        protected virtual void WriteDestinations(UrlHelper urlHelper)
        {
            var destinations = _destinationService.GetAllDestinations(storeId: _storeContext.CurrentStore.Id);

            foreach (var destination in destinations)
            {
                var url = urlHelper.RouteUrl("Destination", new { SeName = destination.GetSeName() }, GetHttpProtocol());
                WriteUrlLocation(url, UpdateFrequency.Weekly, destination.UpdatedOnUtc);
            }
        }
Пример #3
0
        /// <summary>
        /// Get destination list
        /// </summary>
        /// <param name="destinationService">Destination service</param>
        /// <param name="cacheManager">Cache manager</param>
        /// <param name="showHidden">A value indicating whether to show hidden records</param>
        /// <returns>Destination list</returns>
        public static List <SelectListItem> GetDestinationList(IDestinationService destinationService, ICacheManager cacheManager, bool showHidden = false)
        {
            if (destinationService == null)
            {
                throw new ArgumentNullException("destinationService");
            }

            if (cacheManager == null)
            {
                throw new ArgumentNullException("cacheManager");
            }

            string cacheKey  = string.Format(ModelCacheEventConsumer.DESTINATIONS_LIST_KEY, showHidden);
            var    listItems = cacheManager.Get(cacheKey, () =>
            {
                var destinations = destinationService.GetAllDestinations(showHidden: showHidden);
                return(destinations.Select(m => new SelectListItem
                {
                    Text = m.Name,
                    Value = m.Id.ToString()
                }));
            });

            var result = new List <SelectListItem>();

            //clone the list to ensure that "selected" property is not set
            foreach (var item in listItems)
            {
                result.Add(new SelectListItem
                {
                    Text  = item.Text,
                    Value = item.Value
                });
            }

            return(result);
        }
        public ActionResult ProductAddPopup(string btnId, string productIdsInput)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
            {
                return(Content("Access denied"));
            }

            var model = new RequirementModel.AddProductModel();

            //a vendor should have access only to his products
            model.IsLoggedInAsVendor = _workContext.CurrentVendor != null;

            //categories
            model.AvailableCategories.Add(new SelectListItem {
                Text = _localizationService.GetResource("Admin.Common.All"), Value = "0"
            });
            var categories = _categoryService.GetAllCategories(showHidden: true);

            foreach (var c in categories)
            {
                model.AvailableCategories.Add(new SelectListItem {
                    Text = c.GetFormattedBreadCrumb(categories), Value = c.Id.ToString()
                });
            }

            //destinations
            model.AvailableDestinations.Add(new SelectListItem {
                Text = _localizationService.GetResource("Admin.Common.All"), Value = "0"
            });
            foreach (var m in _destinationService.GetAllDestinations(showHidden: true))
            {
                model.AvailableDestinations.Add(new SelectListItem {
                    Text = m.Name, Value = m.Id.ToString()
                });
            }

            //stores
            model.AvailableStores.Add(new SelectListItem {
                Text = _localizationService.GetResource("Admin.Common.All"), Value = "0"
            });
            foreach (var s in _storeService.GetAllStores())
            {
                model.AvailableStores.Add(new SelectListItem {
                    Text = s.Name, Value = s.Id.ToString()
                });
            }

            //vendors
            model.AvailableVendors.Add(new SelectListItem {
                Text = _localizationService.GetResource("Admin.Common.All"), Value = "0"
            });
            foreach (var v in _vendorService.GetAllVendors(showHidden: true))
            {
                model.AvailableVendors.Add(new SelectListItem {
                    Text = v.Name, Value = v.Id.ToString()
                });
            }

            //product types
            model.AvailableProductTypes = ProductType.SimpleProduct.ToSelectList(false).ToList();
            model.AvailableProductTypes.Insert(0, new SelectListItem {
                Text = _localizationService.GetResource("Admin.Common.All"), Value = "0"
            });


            ViewBag.productIdsInput = productIdsInput;
            ViewBag.btnId           = btnId;

            return(View("~/Plugins/DiscountRules.HasOneProduct/Views/ProductAddPopup.cshtml", model));
        }
 public async Task <IActionResult> GetAllDestinations()
 {
     return(Ok(await _destinationService.GetAllDestinations()));
 }
Пример #6
0
        public virtual SitemapModel PrepareSitemapModel()
        {
            string cacheKey = string.Format(ModelCacheEventConsumer.SITEMAP_PAGE_MODEL_KEY,
                                            _workContext.WorkingLanguage.Id,
                                            string.Join(",", _workContext.CurrentCustomer.GetCustomerRoleIds()),
                                            _storeContext.CurrentStore.Id);
            var cachedModel = _cacheManager.Get(cacheKey, () =>
            {
                var model = new SitemapModel
                {
                    BlogEnabled = _blogSettings.Enabled,
                    NewsEnabled = _newsSettings.Enabled,
                };
                //categories
                if (_commonSettings.SitemapIncludeCategories)
                {
                    var categories   = _categoryService.GetAllCategories(storeId: _storeContext.CurrentStore.Id);
                    model.Categories = categories.Select(category => new CategorySimpleModel
                    {
                        Id     = category.Id,
                        Name   = category.GetLocalized(x => x.Name),
                        SeName = category.GetSeName(),
                    }).ToList();
                }
                //destinations
                if (_commonSettings.SitemapIncludeDestinations)
                {
                    var destinations   = _destinationService.GetAllDestinations(storeId: _storeContext.CurrentStore.Id);
                    model.Destinations = destinations.Select(category => new DestinationBriefInfoModel
                    {
                        Id     = category.Id,
                        Name   = category.GetLocalized(x => x.Name),
                        SeName = category.GetSeName(),
                    }).ToList();
                }
                //products
                if (_commonSettings.SitemapIncludeProducts)
                {
                    //limit product to 200 until paging is supported on this page
                    var products = _productService.SearchProducts(storeId: _storeContext.CurrentStore.Id,
                                                                  visibleIndividuallyOnly: true,
                                                                  pageSize: 200);
                    model.Products = products.Select(product => new ProductOverviewModel
                    {
                        Id               = product.Id,
                        Name             = product.GetLocalized(x => x.Name),
                        ShortDescription = product.GetLocalized(x => x.ShortDescription),
                        FullDescription  = product.GetLocalized(x => x.FullDescription),
                        SeName           = product.GetSeName(),
                    }).ToList();
                }

                //topics
                var topics = _topicService.GetAllTopics(_storeContext.CurrentStore.Id)
                             .Where(t => t.IncludeInSitemap)
                             .ToList();
                model.Topics = topics.Select(topic => new TopicModel
                {
                    Id                  = topic.Id,
                    SystemName          = topic.SystemName,
                    IncludeInSitemap    = topic.IncludeInSitemap,
                    IsPasswordProtected = topic.IsPasswordProtected,
                    Title               = topic.GetLocalized(x => x.Title),
                })
                               .ToList();
                return(model);
            });

            return(cachedModel);
        }
 public void LoadData()
 {
     ModelObjects = _destinationService.GetAllDestinations().Select(dest => _destinationMapper.FromDomainToModel(dest)).ToList();
 }