public ActionResult PreviewPage(Guid id, bool import = false, Guid?importToCat = null, int o = 0, int c = 200)
        {
            PageViewModel viewModel = null;

            if (id == Guid.Empty)
            {
                viewModel = new PageViewModel {
                    Id   = Guid.Empty,
                    Name = StringResource.admin_HomeShort
                };
            }
            else
            {
                var page = this.repository.GetPageById(id);

                this.ViewData["ProductItemsViewModel"] =
                    CategoryViewModelFactory.CreateCategoryViewModel(this.HttpContext.CurrentUser(), page, c, o, ListingViewProductSettings.AdminSettings);

                if (page.IsCategory())
                {
                    var category = repository.GetCategoryById(page.CategoryId.Value);
                    this.ViewData["CategoryProducts"] = new CategoryProductsViewModel(this.repository, page.Id, o, c)
                    {
                        IsTiles = category.ListType == 2
                    };
                }

                viewModel = new PageViewModel(page, this.repository);
            }

            this.ViewData["IsImportMode"] = import;
            this.ViewData["importToCat"]  = importToCat;
            return(this.View(viewModel));
        }
Beispiel #2
0
        public async Task <IActionResult> Index()
        {
            var user = await GetCurrentUser();

            var l = await portfolios.GetMedicines(user.Id);

            var catObjs = await categories.GetCategories(user.Id);

            List <CategoryViewModel> categoryViews = new List <CategoryViewModel>();
            List <MedicineObject>    usedMeds      = new List <MedicineObject>();

            foreach (var c in catObjs)
            {
                await categoryMedicines.LoadMedicines(c);

                foreach (var med in c.MedicinesWithCategory)
                {
                    usedMeds.Add(med);
                    await medicineEffects.LoadEffects(med);
                }
                categoryViews.Add(CategoryViewModelFactory.Create(c));
            }

            var allMeds = await medicines.GetObjectsList();

            List <string> duplicateIds = new List <string>();

            for (int i = 0; i < allMeds.Count; i++)
            {
                bool contains = usedMeds.Any(x => x.DbRecord.ID == allMeds[i].DbRecord.ID);
                if (contains)
                {
                    duplicateIds.Add(allMeds[i].DbRecord.ID);
                }
            }

            foreach (var id in duplicateIds)
            {
                var medicine = allMeds.Where(x => x.DbRecord.ID == id).ToList();
                allMeds.Remove(medicine[0]);
            }
            //foreach (var med in allMeds)
            //{
            //    int index = usedMeds.FindIndex(x => x.DbRecord.ID == med.DbRecord.ID);
            //    if (index>=0)
            //    {
            //        allMeds.Remove(med);
            //    }
            //}

            ViewBag.Medicines = allMeds.Select(x => new SelectListItem
            {
                Value = x.DbRecord.ID,
                Text  = x.DbRecord.Name + ", " + x.DbRecord.FormOfInjection + ", " + x.DbRecord.Strength
            }).ToList();

            ViewBag.Categories = categoryViews;
            return(View(PortfolioViewModelFactory.Create(user.Id, l)));
        }
Beispiel #3
0
        public CategoriesController(ICategoryService categoryService, IMessageProvider messageProvider, IMapper mapper)
        {
            _categoryService = categoryService;
            _messageProvider = messageProvider;
            _mapper          = mapper;

            _factory = new CategoryViewModelFactory(_categoryService);
        }
 public CatalogController(InventoryManager inventoryManager, ContactFactory contactFactory, ProductViewModelFactory productViewModelFactory, AccountManager accountManager, CatalogManager catalogManager, GiftCardManager giftCardManager, PricingManager pricingManager, CartManager cartManager, CommerceUserContext commerceUserContext, CatalogItemContext catalogItemContext, CatalogUrlService catalogUrlRepository, StorefrontContext storefrontContext, CategoryViewModelFactory categoryViewModelFactory, GetChildProductsService getChildProductsService)
 {
     InventoryManager         = inventoryManager;
     ProductViewModelFactory  = productViewModelFactory;
     CatalogManager           = catalogManager;
     GiftCardManager          = giftCardManager;
     CommerceUserContext      = commerceUserContext;
     CatalogItemContext       = catalogItemContext;
     StorefrontContext        = storefrontContext;
     CategoryViewModelFactory = categoryViewModelFactory;
     GetChildProductsService  = getChildProductsService;
 }
        private ActionResult ContentPage(ContentPage page, Guid id, User user, int c, int o)
        {
            // Page/Category view
            this.ViewData["BreadcrumbViewModel"]     = MenuViewModelFactory.CreateBreadcrumb(repository, id);
            this.ViewData["NavigationMenuViewModel"] = MenuViewModelFactory.CreateNavigationMenu(repository, id, this.Request);

            var viewModel = new PageViewModel(page, this.repository);

            this.ViewData["ProductItemsViewModel"] = CategoryViewModelFactory.CreateCategoryViewModel(user, page, c, o, ListingViewProductSettings.User);

            this.ViewData["IsPage"] = !viewModel.ContentPage.IsCategory();
            return(this.View(viewModel));
        }
        private CategoryViewModel GetCategoryViewModel(Category category, SearchOptions productSearchOptions = null)
        {
            Assert.IsNotNull(category, nameof(category));

            var cacheKey = CreateCacheKey("Category", category, productSearchOptions);

            var categoryViewModel = this.GetFromCache <CategoryViewModel>(cacheKey);

            if (categoryViewModel != null)
            {
                return(categoryViewModel);
            }
            categoryViewModel = CategoryViewModelFactory.Create(category, productSearchOptions);

            return(this.AddToCache(cacheKey, categoryViewModel));
        }
        public ActionResult CategoryPageHeader()
        {
            if (CatalogManager.CatalogContext == null)
            {
                return(this.InfoMessage(InfoMessage.Error("This rendering cannot be shown without a valid catalog context.")));
            }

            var currentCategory = GetCurrentCategory();

            if (currentCategory == null)
            {
                return(this.InfoMessage(InfoMessage.Error(AlertTexts.InvalidDataSourceTemplateFriendlyMessage)));
            }

            var model = CategoryViewModelFactory.Create(currentCategory);

            return(View(model));
        }
 public void Process(GetPageMetadataArgs args)
 {
     if (CatalogItemContext.IsCategory)
     {
         var category = CategoryViewModelFactory.Create(CatalogItemContext.Current.Item);
         args.Metadata.PageTitle   = category.Title;
         args.Metadata.Description = StringUtil.RemoveTags(category.Description);
     }
     if (CatalogItemContext.IsProduct)
     {
         var product = ProductViewModelFactory.Create(CatalogItemContext.Current.Item);
         args.Metadata.PageTitle   = product.Title;
         args.Metadata.Description = StringUtil.RemoveTags(product.Description);
         foreach (var tag in product.Tags)
         {
             args.Metadata.KeywordsList.Add(tag);
         }
     }
 }
 public SetProductCatalogMetadata(CatalogItemContext catalogItemContext, CategoryViewModelFactory categoryViewModelFactory, ProductViewModelFactory productViewModelFactory)
 {
     CatalogItemContext       = catalogItemContext;
     CategoryViewModelFactory = categoryViewModelFactory;
     ProductViewModelFactory  = productViewModelFactory;
 }
Beispiel #10
0
 public ActionResult Index()
 {
     this.Initialize(Guid.Empty);
     this.ViewData["CategoryTilesViewModel"] = CategoryViewModelFactory.GetPriorityCategories(repository, this.Request);
     return(View());
 }