public CatalogPromotionViewModel(
			IRepositoryFactory<IAppConfigRepository> appConfigRepositoryFactory,
			IRepositoryFactory<IMarketingRepository> repositoryFactory,
			IRepositoryFactory<ICatalogRepository> catalogRepositoryFactory,
			IRepositoryFactory<IPricelistRepository> pricelistRepositoryFactory,
			IViewModelsFactory<ISearchCategoryViewModel> searchCategoryVmFactory,
			IViewModelsFactory<ISearchItemViewModel> searchItemVmFactory,
			IRepositoryFactory<IShippingRepository> shippingRepositoryFactory,
			IMarketingEntityFactory entityFactory,
			INavigationManager navManager,
			Promotion item)
			: base(appConfigRepositoryFactory, repositoryFactory, entityFactory, navManager, item, false, searchCategoryVmFactory, searchItemVmFactory, shippingRepositoryFactory)
		{
			_catalogRepositoryFactory = catalogRepositoryFactory;
			_pricelistRepositoryFactory = pricelistRepositoryFactory;

			ViewTitle = new ViewTitleBase
				{
                    Title = "Promotion",
					SubTitle =
						(item != null && !string.IsNullOrEmpty(item.Name))
							? item.Name.ToUpper(CultureInfo.InvariantCulture)
							: string.Empty
				};
		}
		public CartPromotionOverviewStepViewModel(
			IRepositoryFactory<IMarketingRepository> repositoryFactory, 
			IRepositoryFactory<IStoreRepository> storeRepositoryFactory,
			IMarketingEntityFactory entityFactory, 
			Promotion item)
			: base(null, null, null, null, repositoryFactory, storeRepositoryFactory, entityFactory, item)
        {
        }
		public CatalogPromotionOverviewStepViewModel(
			IRepositoryFactory<IMarketingRepository> repositoryFactory,
			IRepositoryFactory<ICatalogRepository> catalogRepositoryFactory,
			IRepositoryFactory<IPricelistRepository> pricelistRepositoryFactory,
			IMarketingEntityFactory entityFactory, Promotion item)
			: base(null, repositoryFactory, catalogRepositoryFactory, pricelistRepositoryFactory, null, null, null, entityFactory, item)
        {
        }
        public CreateCatalogPromotionViewModel(
			IViewModelsFactory<ICatalogPromotionOverviewStepViewModel> overviewVmFactory, 
			IViewModelsFactory<ICatalogPromotionExpressionStepViewModel> expressionVmFactory, 
			Promotion item)
        {
	        var parametr = new KeyValuePair<string, object>("item", item);

			RegisterStep(overviewVmFactory.GetViewModelInstance(parametr));
			RegisterStep(expressionVmFactory.GetViewModelInstance(parametr));
		}
		protected CartPromotionViewModel(
			IRepositoryFactory<IAppConfigRepository> appConfigRepositoryFactory,
			IRepositoryFactory<IShippingRepository> shippingRepositoryFactory,
			IViewModelsFactory<ISearchCategoryViewModel> searchCategoryVmFactory,
			IViewModelsFactory<ISearchItemViewModel> searchItemVmFactory,
			IRepositoryFactory<IMarketingRepository> repositoryFactory, 
			IRepositoryFactory<IStoreRepository> storeRepositoryFactory,
			IMarketingEntityFactory entityFactory, 
			Promotion item)
			: base(appConfigRepositoryFactory, repositoryFactory, entityFactory, null, item, true, searchCategoryVmFactory, searchItemVmFactory, shippingRepositoryFactory)
		{
			_storeRepositoryFactory = storeRepositoryFactory;
		}
		public CreateCartPromotionViewModel(
			IViewModelsFactory<ICartPromotionOverviewStepViewModel> overviewVmFactory, 
			IViewModelsFactory<ICartPromotionExpressionStepViewModel> expressionVmFactory,
			IViewModelsFactory<ICartPromotionCouponStepViewModel> couponVmFactory,
			Promotion item)
        {
			RegisterStep(overviewVmFactory.GetViewModelInstance(
				new KeyValuePair<string, object>("item", item)));
			RegisterStep(expressionVmFactory.GetViewModelInstance(
				new KeyValuePair<string, object>("item", item)));
			RegisterStep(couponVmFactory.GetViewModelInstance(
				new KeyValuePair<string, object>("item", item)));
        }
		public void RegisterToUsePromotion(IPromotionEvaluationContext context, Promotion promotion)
		{
			var promotionUsage = new PromotionUsage
			{
				CouponCode = context.CouponCode,
				MemberId = context.CustomerId,
				PromotionId = promotion.PromotionId,
				OrderGroupId = ((OrderGroup)context.ContextObject).OrderGroupId
			};

            _marketingRepository.Add(promotionUsage);

            _marketingRepository.UnitOfWork.Commit();
		}
		protected CatalogPromotionViewModel(
			IRepositoryFactory<IAppConfigRepository> appConfigRepositoryFactory,
			IRepositoryFactory<IMarketingRepository> repositoryFactory,
			IRepositoryFactory<ICatalogRepository> catalogRepositoryFactory,
			IRepositoryFactory<IPricelistRepository> pricelistRepositoryFactory,
			IViewModelsFactory<ISearchCategoryViewModel> searchCategoryVmFactory,
			IViewModelsFactory<ISearchItemViewModel> searchItemVmFactory,
			IRepositoryFactory<IShippingRepository> shippingRepositoryFactory,
			IMarketingEntityFactory entityFactory,
			Promotion item)
			: base(appConfigRepositoryFactory, repositoryFactory, entityFactory, null, item, true, searchCategoryVmFactory, searchItemVmFactory, shippingRepositoryFactory)
		{
			_catalogRepositoryFactory = catalogRepositoryFactory;
			_pricelistRepositoryFactory = pricelistRepositoryFactory;
			IsWizardMode = true;
		}
		public CatalogPromotionExpressionStepViewModel(
			IRepositoryFactory<IAppConfigRepository> appConfigRepositoryFactory,
			IRepositoryFactory<IMarketingRepository> repositoryFactory,
			IViewModelsFactory<ISearchCategoryViewModel> searchCategoryVmFactory,
			IViewModelsFactory<ISearchItemViewModel> searchItemVmFactory,
			IRepositoryFactory<IShippingRepository> shippingRepositoryFactory,
			IMarketingEntityFactory entityFactory, Promotion item)
			: base(appConfigRepositoryFactory, repositoryFactory, null, null, searchCategoryVmFactory, searchItemVmFactory, shippingRepositoryFactory, entityFactory, item)
        {
        }
		public CartPromotionCouponStepViewModel(
			IRepositoryFactory<IMarketingRepository> repositoryFactory, 
			IMarketingEntityFactory entityFactory, 
			Promotion item)
			: base(null, null, null, null, repositoryFactory, null, entityFactory, item)
        {
        }
		private PromotionReward AddCatalogReward(Promotion promotion, decimal amount, RewardAmountType amountType)
		{
			var promotionReward = new CatalogItemReward
			{
				Amount = amount,
				AmountTypeId = amountType.GetHashCode(),
				PromotionId = promotion.PromotionId
			};

			MarketingRepository.Add(promotionReward);
			MarketingRepository.UnitOfWork.Commit();

			return promotionReward;
		}