protected virtual void MapConfigurationFields(CategoryNavigationViewModel categoryNavigationViewModel)
        {
            categoryNavigationViewModel.HideMiniBasket        = this.hideMiniBasket;
            categoryNavigationViewModel.AllowChangingCurrency = this.allowChangingCurrency;

            if (this.imageId != Guid.Empty)
            {
                try
                {
                    var manager = LibrariesManager.GetManager();
                    var image   = manager.GetImage(this.imageId);
                    categoryNavigationViewModel.ImageUrl = MediaContentExtensions.ResolveMediaUrl(image, false);
                }
                catch (Exception ex)
                {
                    Log.Write(
                        $"Categories Model: Image cannot be retrieved. Cannot resolve image with Id: {this.imageId} due to the following exception: {Environment.NewLine} {ex}",
                        ConfigurationPolicy.ErrorLog);
                }
            }

            if (this.searchPageId != Guid.Empty)
            {
                var nextSearchUrl = UrlResolver.GetPageNodeUrl(this.searchPageId);

                if (nextSearchUrl != null)
                {
                    categoryNavigationViewModel.SearchPageUrl = nextSearchUrl;
                }
            }
        }
        public ActionResult Index()
        {
            CategoryNavigationViewModel categoryNavigationViewModel = null;

            try
            {
                var    model = this.ResolveModel();
                string message;

                var parameters = new System.Collections.Generic.Dictionary <string, object>();

                if (!model.CanProcessRequest(parameters, out message))
                {
                    return(this.PartialView("_Warning", message));
                }

                categoryNavigationViewModel = model.CreateViewModel();

                var detailTemplateName = this.detailTemplateNamePrefix + this.TemplateName;

                return(this.View(detailTemplateName, categoryNavigationViewModel));
            }
            catch (Exception ex)
            {
                if (UCommerceUIModule.TryHandleSystemError(ex, out ActionResult actionResult))
                {
                    return(actionResult);
                }
                else
                {
                    throw;
                }
            }
        }
        public ActionResult StoreNavigation(Guid categoryPageId)
        {
            CategoryNavigationViewModel categoryNavigationViewModel = null;

            this.CategoryPageId = categoryPageId;
            try
            {
                var    model = this.ResolveModel();
                string message;

                var parameters = new System.Collections.Generic.Dictionary <string, object>();

                if (!model.CanProcessRequest(parameters, out message))
                {
                    return(this.PartialView("_Warning", message));
                }

                categoryNavigationViewModel = model.CreateViewModel();
                return(View(categoryNavigationViewModel));
            }
            catch (Exception ex)
            {
                if (UCommerceUIModule.TryHandleSystemError(ex, out ActionResult actionResult))
                {
                    return(actionResult);
                }
                else
                {
                    throw;
                }
            }
        }
        public virtual CategoryNavigationViewModel CreateViewModel()
        {
            var categoryNavigationViewModel = new CategoryNavigationViewModel();
            var rootCategories    = CatalogLibrary.GetRootCategories().Where(x => x.DisplayOnSite).ToList();
            var currentPriceGroup = SiteContext.Current.CatalogContext.CurrentPriceGroup;

            categoryNavigationViewModel.Categories      = this.MapCategories(rootCategories, SiteContext.Current.CatalogContext.CurrentCategory);
            categoryNavigationViewModel.Currencies      = this.MapCurrencies(SiteContext.Current.CatalogContext.CurrentCatalog.AllowedPriceGroups, currentPriceGroup);
            categoryNavigationViewModel.CurrentCurrency = new CategoryNavigationCurrencyViewModel()
            {
                DisplayName  = currentPriceGroup.Name,
                PriceGroupId = currentPriceGroup.PriceGroupId,
            };

            categoryNavigationViewModel.ProductDetailsPageId = this.productDetailsPageId;

            this.MapConfigurationFields(categoryNavigationViewModel);

            categoryNavigationViewModel.Routes.Add(RouteConstants.SEARCH_ROUTE_NAME, RouteConstants.SEARCH_ROUTE_VALUE);
            categoryNavigationViewModel.Routes.Add(RouteConstants.SEARCH_SUGGESTIONS_ROUTE_NAME, RouteConstants.SEARCH_SUGGESTIONS_ROUTE_VALUE);
            categoryNavigationViewModel.Routes.Add(RouteConstants.PRICE_GROUP_ROUTE_NAME, RouteConstants.PRICE_GROUP_ROUTE_VALUE);
            categoryNavigationViewModel.Routes.Add(RouteConstants.GET_BASKET_ROUTE_NAME, RouteConstants.GET_BASKET_ROUTE_VALUE);

            return(categoryNavigationViewModel);
        }
Exemplo n.º 5
0
        private void OnAddNewCategoryExecute(int?obj)
        {
            var strkey = obj.ToString();

            AddCategoryViewModel vm = new AddCategoryViewModel()
            {
                CategoryTitle = "Новая категория"
            };

            int.TryParse(strkey, out int parentKey);


            AddCategoryDialog dlg = new AddCategoryDialog()
            {
                DataContext = vm
            };
            var result = dlg.ShowDialog();

            if (result == true)
            {
                Category category = new Category()
                {
                    CategoryTitle = vm.CategoryTitle
                };
                if (parentKey > 0)
                {
                    category.ParentCategoryKey = parentKey;
                }

                _categoryRepository.Add(category);
                _categoryRepository.Save();
                CategoryNavigationViewModel.Load();
            }
        }
Exemplo n.º 6
0
        public ActionResult CategoryNavigation(string slug)
        {
            var categoryNavigation = new CategoryNavigationViewModel
            {
            };

            return(View("/views/mc/PartialViews/CategoryNavigation.cshtml", categoryNavigation));
        }
        public ActionResult CategoryNavigation()
        {
            var categoryNavigation = new CategoryNavigationViewModel();

            categoryNavigation.Categories = MapUCommerceCategories(UCommerce.Api.CatalogLibrary.GetRootCategories());

            return(View("/views/PartialViews/CategoryNavigation.cshtml", categoryNavigation));
        }
Exemplo n.º 8
0
        public CategoryNavigationView()
        {
            InitializeComponent();

            if (BindingContext == null)
            {
                BindingContext = new CategoryNavigationViewModel();
            }
        }
        // GET: PartialView
        public ActionResult CategoryNavigation()
        {
            var cn = new CategoryNavigationViewModel();
            ICollection <Category> rootCategories = CatalogLibrary.GetRootCategories();

            cn.Categories = MapCategories(rootCategories);

            return(View("/views/PartialView/CategoryNavigation.cshtml", cn));
        }
Exemplo n.º 10
0
        public ActionResult CategoryNavigation()
        {
            var categoryNavigationModel = new CategoryNavigationViewModel();

            ICollection <Category> rootCategories = CatalogLibrary.GetRootCategories();

            categoryNavigationModel.Categories = MapCategories(rootCategories);

            return(View("/views/PartialView/_HeaderMainMenuCategoryNav.cshtml", categoryNavigationModel));
        }
        public ActionResult CategoryNavigation()
        {
            var categoryNavigationModel = new CategoryNavigationViewModel();

            IEnumerable <Category> rootCategories = CatalogLibrary.GetRootCategories().ToList();

            categoryNavigationModel.Categories = MapCategories(rootCategories);

            return(View("/views/PartialView/CategoryNavigation.cshtml", categoryNavigationModel));
        }
        public ActionResult CategoryNavigation()
        {
            var categoryNavigationModel = new CategoryNavigationViewModel();

            ICollection <Category> rootCategories = CatalogLibrary.GetRootCategories().Where(x => x.DisplayOnSite).ToList();

            categoryNavigationModel.Categories = MapCategories(rootCategories);

            return(View("/views/PartialView/CategoryNavigation.cshtml", categoryNavigationModel));
        }
        public virtual CategoryNavigationViewModel CreateViewModel()
        {
            var categoryNavigationViewModel = new CategoryNavigationViewModel();
            // HACK: This is a temporary work around while we dig into the best way to do this with the new API
            var rootCategoryGuids = CatalogLibrary.GetRootCategories().Select(c => c.Guid);
            var rootCategories    = Ucommerce.EntitiesV2.Category.Find(c => rootCategoryGuids.Contains(c.Guid));
            var currentCategory   = CatalogContext.CurrentCategory != null?Ucommerce.EntitiesV2.Category.FirstOrDefault(x => x.Guid == CatalogContext.CurrentCategory.Guid) : null;

            categoryNavigationViewModel.Categories = this.MapCategories(rootCategories, currentCategory);

            var priceGroups       = Ucommerce.EntitiesV2.PriceGroup.Find(x => CatalogContext.CurrentCatalog.PriceGroups.Contains(x.Guid));
            var currentPriceGroup = Ucommerce.EntitiesV2.PriceGroup.FirstOrDefault(x => x.Guid == CatalogContext.CurrentPriceGroup.Guid);

            categoryNavigationViewModel.Currencies      = this.MapCurrencies(priceGroups, currentPriceGroup);
            categoryNavigationViewModel.Localizations   = this.GetCurrentCulture();
            categoryNavigationViewModel.CurrentCurrency = new CategoryNavigationCurrencyViewModel()
            {
                DisplayName  = currentPriceGroup.Name,
                PriceGroupId = currentPriceGroup.PriceGroupId,
            };
            GetCurrentCulture();

            categoryNavigationViewModel.ProductDetailsPageId = this.productDetailsPageId;

            this.MapConfigurationFields(categoryNavigationViewModel);

            categoryNavigationViewModel.Routes.Add(RouteConstants.SEARCH_ROUTE_NAME, RouteConstants.SEARCH_ROUTE_VALUE);
            categoryNavigationViewModel.Routes.Add(RouteConstants.SEARCH_SUGGESTIONS_ROUTE_NAME,
                                                   RouteConstants.SEARCH_SUGGESTIONS_ROUTE_VALUE);
            categoryNavigationViewModel.Routes.Add(RouteConstants.PRICE_GROUP_ROUTE_NAME,
                                                   RouteConstants.PRICE_GROUP_ROUTE_VALUE);
            categoryNavigationViewModel.Routes.Add(RouteConstants.GET_BASKET_ROUTE_NAME,
                                                   RouteConstants.GET_BASKET_ROUTE_VALUE);

            if (this.categoryPageId == Guid.Empty)
            {
                categoryNavigationViewModel.BaseUrl = UrlResolver.GetCurrentPageNodeUrl();
            }
            else
            {
                categoryNavigationViewModel.BaseUrl = UrlResolver.GetAbsoluteUrl(UrlResolver.GetPageNodeUrl(this.categoryPageId));
            }

            return(categoryNavigationViewModel);
        }
Exemplo n.º 14
0
        public FilesOnDriveViewModel(
            IEventAggregator eventAggregator
            , IMessageDialogService messageDialogService
            , IArchiveEntityRepository repository
            , ICategoryNavigationViewModel categoryNavigationViewModel
            , ICategoryRepository categoryRepository
            , ITagRepository tagRepository
            , IAppLogger appLogger
            ) : base(eventAggregator, messageDialogService, appLogger)
        {
            _categoryRepository          = categoryRepository;
            _categoryNavigationViewModel = categoryNavigationViewModel;
            _tagRepository        = tagRepository;
            _repository           = repository;
            _eventAggregator      = eventAggregator;
            _messageDialogService = messageDialogService;
            _eventAggregator.GetEvent <SelectedItemChangedEvent>().Subscribe(OnSelectedItemChanged);

            Tags       = new ObservableCollection <TagWrapper>();
            Categories = new ObservableCollection <CategoryWrapper>();
            Images     = new ObservableCollection <ImageWrapper>();

            CategoryNavigationViewModel.Load();

            #region Commands
            AddTagCommand = new DelegateCommand <string>(OnAddTagExecute, OnAddTagCanExecute);

            MultyAddTagCommand = new DelegateCommand <string>(OnAddMultyTagExecute, OnAddMultyTagCanExecute);

            AddCategoryCommand                = new DelegateCommand <int?>(OnAddCategoryExecute, OnAddCategoryCanExecute);
            AddNewCategoryCommand             = new DelegateCommand <int?>(OnAddNewCategoryExecute, OnAddNewCategoryCanExecute);
            OpenFileDialogCommand             = new DelegateCommand(OnOpenFileDialogExecute, OnOpenFileDialogCanExecute);
            DeleteTagCommand                  = new DelegateCommand <string>(OnDeleteTagExecute, OnDeleteTagCanExecute);
            DeleteImageCommand                = new DelegateCommand <int?>(OnDeleteImageExecute, OnDeleteImageCanExecute);
            DeleteCategoryToEntityCommand     = new DelegateCommand <int?>(OnDeleteCategoryToEntityExecute, OnDeleteCategoryToEntityCanExecute);
            CloseSearchDetailViewModelCommand = new DelegateCommand(OnCloseSearchDetailViewExecute);
            EditDescriptionCommand            = new DelegateCommand(OnEditDescriptionViewExecute);
            MultyAddCategoryCommand           = new DelegateCommand <int?>(OnMultyAddCategoryExecute, OnMultyAddCategoryCanExecute);

            #endregion
        }
Exemplo n.º 15
0
        public ActionResult CategoryNavigation(int partialViewType)
        {
            var categoryNavigationModel = new CategoryNavigationViewModel();

            IEnumerable <Category> rootCategories = CatalogLibrary.GetRootCategories().ToList();

            categoryNavigationModel.Categories = MapCategories(rootCategories);

            switch (partialViewType)
            {
            case (int)PartialTypes.CategoryNavigation:
                return(View("/views/PartialView/CategoryNavigation.cshtml", categoryNavigationModel));

            case (int)PartialTypes.SiteWideCategoryNavigation:
                return(View("/views/PartialView/SiteWideCategoryNavigation.cshtml", categoryNavigationModel));

            case (int)PartialTypes.FeaturedCategoryNavigation:
                return(View("/views/PartialView/FeaturedCategoryNavigation.cshtml", categoryNavigationModel));

            default:
                return(View("/views/PartialView/CategoryNavigation.cshtml", categoryNavigationModel));
            }
        }
        public async Task LoadAsync()
        {
            await CategoryNavigationViewModel.LoadAsync();

            await TagNavigationViewModel.LoadAsync();
        }
 public void Load()
 {
     CategoryNavigationViewModel.Load();
     TagNavigationViewModel.Load();
 }
Exemplo n.º 18
0
        public ActionResult CategoryNavigation()
        {
            var model = new CategoryNavigationViewModel();

            return(View("/views/CategoryNavigation/index.cshtml", model));
        }