private ICartItemViewModel CustomJewelCartItemViewModelBuilderMethod(ICartItem cartItem, int index)
        {
            try
            {
                var customJewel = cartItem as CustomJewelCartItem;
                jewelRepository.FilterMediaByMetal(customJewel.MediaType);
                var diamond = diamondRepository.GetDiamondByID(customJewel.DiamondID);
                var jewel   = jewelRepository.GetJewelByID(customJewel.SettingID);

                var twoObjects = new MergeDiamondAndJewel()
                {
                    First  = diamond,
                    Second = jewel
                };


                var viewModel = mapper.Map <MergeDiamondAndJewel, CustomJewelCartItemViewModel>(twoObjects);
                viewModel.CartID = index;
                viewModel.Size   = customJewel.GetSize();
                return(viewModel);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message +
                                    "\n When asked to build a view model for jewelcartitem we had a problem explained above");
            }
        }
Пример #2
0
        public TOut LoadJewelryCollection <TOut>(TOut viewModel) where TOut : ITabsViewModel
        {
            var dynamicSQLObject = GetDynamicSQLStringBytabKeyAndID(tabKey, tabId);

            jewelRepository.Page(page);
            jewelRepository.ItemsPerPage(itemsPerPage);



            var jewelMediaType = JewelMediaTypeFilter.Value;

            jewelRepository.FilterMediaByMetal(jewelMediaType);
            jewelRepository.OrderJewelryItemsBy(OrderByPriceFilter.DynamicOrderBy());

            if (CustomFiltersStateList.Count > 0)
            {
                var dynamicSQLList =
                    CustomFiltersStateList.Select(x => ConvertCustomFilterStateToDynamicSQL(x)).ToList();

                jewelRepository.AddFilterList(dynamicSQLList);
            }


            var jewelList = jewelRepository.GetJewelsByDynamicSQL(dynamicSQLObject);

            viewModel.JewelryInTabContainersCollection = MapJewelsToInTabContainers(jewelList);

            var totalItems = jewelRepository.TotalItems;

            viewModel.TotalPages = CalculateTotalPages(totalItems);

            return(viewModel);
        }
Пример #3
0
        public ActionResult Index(int id, JewelMediaType?nullableMediaSet)
        {
            var mediaSet = nullableMediaSet ?? JewelMediaType.WhiteGold;

            jewelRepository.FilterMediaByMetal(mediaSet);

            var builder = new JewelryItemViewModelBuilder(id, jewelRepository, testimonailRepository, fileSystem, mapper);

            try
            {
                var viewModel = builder.Build();
                viewModel.PathBarItems = pathBarGenerator.GenerateUsing <UsingDynamicTitlePathBarResolver, dynamic>(viewModel);

                return(View(viewModel));
            }
            catch (ArgumentNullException)
            {
                throw new ArgumentNullException("Bad Request for an item");
            }
        }
Пример #4
0
        public ActionResult Setting(CustomJewelPersistenceForSetting customJewelPersistenceForSetting)
        {
            var tabsForJewelNavigation = new TabsForJewelDesignNavigationBuilder(customJewelPersistenceForSetting, diamondRepository,
                                                                                 jewelRepository, webHelpers);

            tabsForJewelNavigation.WhichTabToHighLight(NagivationTabType.ChooseSetting);

            jewelRepository.FilterMediaByMetal(customJewelPersistenceForSetting.MediaType == 0 ? JewelMediaType.WhiteGold : customJewelPersistenceForSetting.MediaType);

            var jewelryItemViewModelBuilder = new JewelryItemViewModelBuilder(customJewelPersistenceForSetting.SettingID, jewelRepository, testimonialRepository, fileSystem, mapper);

            var builder = new SettingViewModelBuilder(customJewelPersistenceForSetting, tabsForJewelNavigation, jewelryItemViewModelBuilder);

            var viewModel = builder.Build();

            viewModel.PathBarItems = pathBarGenerator.GenerateUsing <UsingDynamicTitlePathBarResolver, dynamic>(viewModel);


            return(View(viewModel));
        }
Пример #5
0
        public EndViewModel Build()
        {
            var mapperHelp = new MergeDiamondAndJewel();

            mapperHelp.First = diamondRepository.GetDiamondByID(customJewelPersistenceInEndPage.DiamondID);

            jewelRepository.FilterMediaByMetal(customJewelPersistenceInEndPage.MediaType);
            mapperHelp.Second = jewelRepository.GetJewelByID(customJewelPersistenceInEndPage.SettingID);

            var viewModel = mapper.Map <MergeDiamondAndJewel, EndViewModel>(mapperHelp);

            viewModel.TabsForJewelDesignNavigation = tabsForJewelDesignBuilder.Build();

            viewModel.JewelPersistence = new CustomJewelPersistenceBase()
            {
                DiamondID = customJewelPersistenceInEndPage.DiamondID,
                SettingID = customJewelPersistenceInEndPage.SettingID,
                Size      = customJewelPersistenceInEndPage.Size,
                MediaType = customJewelPersistenceInEndPage.MediaType
            };


            return(viewModel);
        }