public DiamondCartItem DiamondCartItem(int id)
        {
            var diamond = diamondRepository.GetDiamondByID(id);
            var price   = diamond.Price;

            return(new DiamondCartItem(id, price));
        }
        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");
            }
        }
Ejemplo n.º 3
0
        public List <NavigationTab> Build()
        {
            var list = new List <NavigationTab>();

            if (customJewelPersistenceBase.DiamondID > 0)
            {
                diamond = diamondRepository.GetDiamondByID(customJewelPersistenceBase.DiamondID);
            }

            if (customJewelPersistenceBase.SettingID > 0)
            {
                setting = jewelRepository.GetJewelByID(customJewelPersistenceBase.SettingID);
            }



            var diamondTab = BuildDiamondTab();

            list.Add(diamondTab);

            var settingTab = BuildSettingTab();

            list.Add(settingTab);

            var finalTab = BuildFinalTab();

            list.Add(finalTab);


            list = list.Select(ForEachTabEvaluateTheHighlightCSSClass).ToList();


            return(list);
        }
Ejemplo n.º 4
0
        protected override List <ICartItem> ResolveCore(acc_ORDERS source)
        {
            try
            {
                var cartItems = new List <ICartItem>();

                var jewelItems = source.acc_JEWELRY_ORDER_ITEMS.ToList();
                foreach (var jewelItem in jewelItems)
                {
                    var dbJewel       = jewelRepository.GetJewelByID(jewelItem.Item_id);
                    var jewelCartItem = new JewelCartItem(jewelItem.Item_id, (JewelMediaType)jewelItem.metal, (decimal)dbJewel.Price);

                    jewelCartItem.SetSize(jewelItem.jewelsize);

                    cartItems.Add(jewelCartItem);
                }

                var diamondItems = source.acc_DIAMOND_ORDER_ITEMS.ToList();
                foreach (var diamondItem in diamondItems)
                {
                    var dbDiamond       = diamondRepository.GetDiamondByID(diamondItem.Item_id);
                    var diamondCartItem = new DiamondCartItem(diamondItem.Item_id, dbDiamond.Price);
                    cartItems.Add(diamondCartItem);
                }

                var customJewelItems = source.acc_CUSTOMJEWEL_ORDER_ITEMS.ToList();

                foreach (var customJewelItem in customJewelItems)
                {
                    var dbsetting = jewelRepository.GetJewelByID(customJewelItem.Setting_id);
                    var dbdiamond = diamondRepository.GetDiamondByID(customJewelItem.Diamond_id);

                    var customJewelCartItem = new CustomJewelCartItem(customJewelItem.Diamond_id,
                                                                      customJewelItem.Setting_id, customJewelItem.size, JewelMediaType.WhiteGold,
                                                                      dbdiamond.Price + (decimal)dbsetting.Price);


                    cartItems.Add(customJewelCartItem);
                }

                return(cartItems);
            }
            catch (Exception ex)
            {
                throw new Exception("When asked to convert from a db order object to a Order POCO:\r\n ordernumber=" + source.OrderNumber + "\r\n" + " an error occured:" + ex.Message);
            }
        }
Ejemplo n.º 5
0
        public DiamondViewModel Build()
        {
            var diamond = diamondRepository.GetDiamondByID(customJewelPersistence.DiamondID);
            //stage one we map
            var viewModel = mapper.Map <Diamond, DiamondViewModel>(diamond);

            //stage 2 we add things that we don't want to map
            viewModel.TabsForJewelDesignNavigation = tabsForJewelDesignNavigationBuilder.Build();

            viewModel.JewelPersistence = customJewelPersistence;

            viewModel.DiamondHelp = diamondHelpBuilder.Build(diamond);

            return(viewModel);
        }
Ejemplo n.º 6
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);
        }