public CategoryPageViewModel(IProductCatalogRepository productCatalogRepository, INavigationService navigationService, IAlertMessageService alertMessageService, IResourceLoader resourceLoader)
 {
     _productCatalogRepository = productCatalogRepository;
     _navigationService = navigationService;
     _alertMessageService = alertMessageService;
     _resourceLoader = resourceLoader;
 }
Exemple #2
0
 public CategoryPageViewModel(IProductCatalogRepository productCatalogRepository, INavigationService navigationService, IAlertMessageService alertMessageService, IResourceLoader resourceLoader)
 {
     _productCatalogRepository = productCatalogRepository;
     _navigationService        = navigationService;
     _alertMessageService      = alertMessageService;
     _resourceLoader           = resourceLoader;
 }
 public ProductCatalogController(IEShopLogger <ProductCatalogController> logger, IProductCatalogRepository repository)
 {
     _logger     = logger;
     _repository = repository;
     //_httpContextAccessor = httpContextAccessor;
     //_currentUser = _httpContextAccessor.CurrentUser();
 }
        public void LoadParts(string sku)
        {
            try
            {
                IProductCatalogRepository productCatalogRepository =
                    SharePointServiceLocator.Current.GetInstance <IProductCatalogRepository>();

                IEnumerable <Part> parts = productCatalogRepository.GetPartsByProductSku(sku);
                if (parts != null && parts.Any())
                {
                    view.Parts = parts;
                }
                else
                {
                    // Show an errormessage in the view. Note, we couldn't use the ErrorVisualizer here, because
                    // the errorVisualizer is outside of the updatepanel. Only things inside the update panel of
                    // the view will be refreshed when the LoadParts button is clicked.
                    view.ErrorMessage = Resources.NoPartsFoundError;
                }
                view.DataBind();
            }
            catch (Exception ex)
            {
                // If an unhandled exception occurs in the view, then instruct the ErrorVisualizer to replace
                // the view with an errormessage.
                ViewExceptionHandler viewExceptionHandler = new ViewExceptionHandler();
                viewExceptionHandler.HandleViewException(ex, ErrorVisualizer);
            }
        }
 public SearchResultsPageViewModel(IProductCatalogRepository productCatalogRepository, INavigationService navigationService, ISearchPaneService searchPaneService)
 {
     _productCatalogRepository = productCatalogRepository;
     _navigationService = navigationService;
     _searchPaneService = searchPaneService;
     ProductNavigationAction = NavigateToItem;
     GoBackCommand = new DelegateCommand(_navigationService.GoBack, _navigationService.CanGoBack);
 }
 // <snippet303>
 public HubPageViewModel(IProductCatalogRepository productCatalogRepository, INavigationService navigationService, IAlertMessageService alertMessageService, IResourceLoader resourceLoader, ISearchPaneService searchPaneService)
 {
     _productCatalogRepository = productCatalogRepository;
     _navigationService = navigationService;
     _alertMessageService = alertMessageService;
     _resourceLoader = resourceLoader;
     _searchPaneService = searchPaneService;
     ProductNavigationAction = NavigateToItem;
     GoBackCommand = new DelegateCommand(navigationService.GoBack, navigationService.CanGoBack);
 }
Exemple #7
0
        public ItemDetailPageViewModel(IProductCatalogRepository productCatalogRepository, IShoppingCartRepository shoppingCartRepository, IAlertMessageService alertMessageService, IResourceLoader resourceLoader, ISecondaryTileService secondaryTileService)
        {
            _productCatalogRepository = productCatalogRepository;
            _shoppingCartRepository   = shoppingCartRepository;
            _alertService             = alertMessageService;
            _resourceLoader           = resourceLoader;
            _secondaryTileService     = secondaryTileService;

            PinProductCommand   = new DelegateCommand(async() => await PinProduct(), () => SelectedProduct != null);
            UnpinProductCommand = new DelegateCommand(async() => await UnpinProduct(), () => SelectedProduct != null);
        }
        public ItemDetailPageViewModel(IProductCatalogRepository productCatalogRepository, IShoppingCartRepository shoppingCartRepository, IAlertMessageService alertMessageService, IResourceLoader resourceLoader, ISecondaryTileService secondaryTileService)
        {
            _productCatalogRepository = productCatalogRepository;
            _shoppingCartRepository = shoppingCartRepository;
            _alertService = alertMessageService;
            _resourceLoader = resourceLoader;
            _secondaryTileService = secondaryTileService;

            PinProductCommand = DelegateCommand.FromAsyncHandler(PinProduct, () => SelectedProduct != null);
            UnpinProductCommand = DelegateCommand.FromAsyncHandler(UnpinProduct, () => SelectedProduct != null);
        }
 public SearchUserControlViewModel(INavigationService navigationService, IProductCatalogRepository productCatalogRepository, IEventAggregator eventAggregator, IResourceLoader resourceLoader)
 {
     _navigationService = navigationService;
     _productCatalogRepository = productCatalogRepository;
     _eventAggregator = eventAggregator;
     _resourceLoader = resourceLoader;
     this.SearchCommand = new DelegateCommand<SearchBoxQuerySubmittedEventArgs>(SearchBoxQuerySubmitted);
     this.SearchSuggestionsCommand = new DelegateCommand<SearchBoxSuggestionsRequestedEventArgs>(async (eventArgs) =>
     {
         await SearchBoxSuggestionsRequested(eventArgs);
     });
 }
 public SearchUserControlViewModel(INavigationService navigationService, IProductCatalogRepository productCatalogRepository, IEventAggregator eventAggregator, IResourceLoader resourceLoader)
 {
     _navigationService            = navigationService;
     _productCatalogRepository     = productCatalogRepository;
     _eventAggregator              = eventAggregator;
     _resourceLoader               = resourceLoader;
     this.SearchCommand            = new DelegateCommand <SearchBoxQuerySubmittedEventArgs>(SearchBoxQuerySubmitted);
     this.SearchSuggestionsCommand = new DelegateCommand <SearchBoxSuggestionsRequestedEventArgs>(async(eventArgs) =>
     {
         await SearchBoxSuggestionsRequested(eventArgs);
     });
 }
        public ItemDetailPageViewModel(IProductCatalogRepository productCatalogRepository, INavigationService navigationService, IShoppingCartRepository shoppingCartRepository, IAlertMessageService alertMessageService, IResourceLoader resourceLoader, ITileService tileService, ISearchPaneService searchPaneService)
        {
            _productCatalogRepository = productCatalogRepository;
            _shoppingCartRepository = shoppingCartRepository;
            _alertService = alertMessageService;
            _resourceLoader = resourceLoader;
            _tileService = tileService;
            _searchPaneService = searchPaneService;
            _isAppBarSticky = false;

            GoBackCommand = new DelegateCommand(navigationService.GoBack, navigationService.CanGoBack);
            AddToCartCommand = DelegateCommand.FromAsyncHandler(AddToCart, CanAddToCart);
            // <snippet802>
            PinProductCommand = DelegateCommand.FromAsyncHandler(PinProduct, () => SelectedProduct != null);
            // </snippet802>
            // <snippet805>
            UnpinProductCommand = DelegateCommand.FromAsyncHandler(UnpinProduct, () => SelectedProduct != null);
            // </snippet805>
        }
        public override void Initialize(string name, System.Collections.Specialized.NameValueCollection attributes)
        {
            if (!this.isInitialized)
            {
                base.Initialize(name, attributes);

                try
                {
                    productCatalogRepository = SharePointServiceLocator.Current.GetInstance <IProductCatalogRepository>();
                    this.profileUrl          = productCatalogRepository.GetCategoryProfileUrl();

                    this.isInitialized = true;
                }
                catch (Exception ex)
                {
                    this.logger.LogToOperations(ex);
                }
            }
        }
        public override void Validate()
        {
            base.Validate();

            if (this.IsValid)
            {
                string sku = (string)this.Value;

                // 1. Check to make sure the product sku is not empty
                if (string.IsNullOrEmpty(sku))
                {
                    this.IsValid      = false;
                    this.ErrorMessage = Resources.ProductCanNotBeEmpty;
                    return;
                }
                else
                {
                    // 2. Validate that the product sku is in the right format
                    RegexStringValidator regexStringValidator = new RegexStringValidator(ProductSkuRegEx);
                    try
                    {
                        regexStringValidator.Validate(sku);
                    }
                    catch (ArgumentException)
                    {
                        this.IsValid      = false;
                        this.ErrorMessage = Resources.InvalidProductSkuFormat;
                        return;
                    }

                    // 3. Validate that the product sku exists in the product catalog system
                    IProductCatalogRepository productCatalogRepository =
                        SharePointServiceLocator.Current.GetInstance <IProductCatalogRepository>();

                    if (productCatalogRepository.GetProductBySku(sku) == null)
                    {
                        this.IsValid      = false;
                        this.ErrorMessage = Resources.ProductNotFound;
                        return;
                    }
                }
            }
        }
        public void LoadProduct(string sku)
        {
            try
            {
                // Write a trace message, that might help in debugging a particular problem. Trace messages should be directed
                // towards developers, and can contain deep technical information. In contrast, Eventlog messages are targeted to operations
                // and should be more actionable.
                logger.TraceToDeveloper(Resources.StartLoadingMessage);

                // Get the product catalog from the ServiceLocator. Because this presenter only knows about the IProductCatalog
                // interface, it can be tested in isolation. In the unit tests, you'll see a MockProductDatalogRepository being used.
                // The actual implementation is provided by the Contoso.LOB.Services.Client project. In the it's WebAppFeatureReceiver
                // You'll see how the actual ProductCatalogRepository is registered with the ServiceLocatorConfig.
                IProductCatalogRepository productCatalogRepository =
                    SharePointServiceLocator.Current.GetInstance <IProductCatalogRepository>();

                Product product = productCatalogRepository.GetProductBySku(sku);

                if (product == null || product.Sku == null)
                {
                    // Show an error message to the user.
                    new ViewExceptionHandler().ShowFunctionalErrorMessage(Resources.CouldNotFindProductInformation,
                                                                          this.ErrorVisualizer);
                }
                else
                {
                    this.view.Product = product;
                    this.view.DataBind();
                }

                logger.TraceToDeveloper(Resources.EndLoadProductMessage
                                        );
            }
            catch (Exception ex)
            {
                // If something goes wrong, make sure the error gets logged
                // and a non technical message is displayed to the user
                new ViewExceptionHandler().HandleViewException(ex, this.ErrorVisualizer,
                                                               Contoso.PartnerPortal.ProductCatalog.Properties.Resources.ProductDetailsErrorMessage);
            }
        }
        public ShoppingCartRepository(IShoppingCartService shoppingCartService, IAccountService accountService, IEventAggregator eventAggregator, IProductCatalogRepository productCatalogRepository, ISuspensionManagerState suspensionManagerState)
        {
            _shoppingCartService = shoppingCartService;
            _accountService = accountService;
            _eventAggregator = eventAggregator;
            _productCatalogRepository = productCatalogRepository;
            _suspensionManagerState = suspensionManagerState;

            if (accountService != null)
            {
                _accountService.UserChanged += _accountService_UserChanged;
            }

            if (_suspensionManagerState != null && _suspensionManagerState.SessionState.ContainsKey(ShoppingCartIdKey))
            {
                _shoppingCartId = _suspensionManagerState.SessionState[ShoppingCartIdKey].ToString();
            }
            else
            {
                _shoppingCartId = Guid.NewGuid().ToString();
                _suspensionManagerState.SessionState[ShoppingCartIdKey] = _shoppingCartId;
            }
        }
Exemple #16
0
 public AutofacOfWork(
     ITestRepositories testRepositories,
     IUserRepository userRepository,
     IUserSettingsRepository userSettingsRepository,
     IDealerRepository dealerRepository,
     ICompanyRepository companyRepository,
     ICategoryRepository categoryRepository,
     IProductRepository productRepository,
     IProductCatalogRepository productCatalogRepository,
     IProductCardRepository productCardRepository,
     IOrderRepository orderRepository
     )
 {
     TestRepositories         = testRepositories;
     UserRepository           = userRepository;
     UserSettingsRepository   = userSettingsRepository;
     DealerRepository         = dealerRepository;
     CompanyRepository        = companyRepository;
     CategoryRepository       = categoryRepository;
     ProductRepository        = productRepository;
     ProductCatalogRepository = productCatalogRepository;
     ProductCardRepository    = productCardRepository;
     OrderRepository          = orderRepository;
 }
Exemple #17
0
 public GetProductCatalogListQueryHandler(IProductCatalogRepository productCatalogRepository, IMapper mapper)
 {
     this._productCatalogRepository = productCatalogRepository;
     this._mapper = mapper;
 }
 public GroupDetailPageViewModel(IProductCatalogRepository productCatalogRepository, IAlertMessageService alertMessageService, IResourceLoader resourceLoader)
 {
     _productCatalogRepository = productCatalogRepository;
     _alertMessageService      = alertMessageService;
     _resourceLoader           = resourceLoader;
 }
 public SearchResultsPageViewModel(IProductCatalogRepository productCatalogRepository, IResourceLoader resourceLoader, IAlertMessageService alertMessageService)
 {
     _productCatalogRepository = productCatalogRepository;
     _resourceLoader = resourceLoader;
     _alertMessageService = alertMessageService;
 }
 public GroupDetailPageViewModel(IProductCatalogRepository productCatalogRepository, IAlertMessageService alertMessageService, IResourceLoader resourceLoader)
 {
     _productCatalogRepository = productCatalogRepository;
     _alertMessageService = alertMessageService;
     _resourceLoader = resourceLoader;
 }
Exemple #21
0
 public DeleteProductCatalogHandler(IProductCatalogRepository productCatalogRepository, IMediator mediator)
 {
     this._productCatalogRepository = productCatalogRepository;
     this._mediator = mediator;
 }
 public ProductCatalogService(IProductCatalogRepository repo,
                             IUnitOfWork unitOfWork)
 {
     this.productCatalogRepository = repo;
     this.unitOfWork = unitOfWork;
 }
Exemple #23
0
 public PriceService(IProductCatalogRepository productCatalogRepository)
 {
     _productCatalogRepository = productCatalogRepository;
 }
 public ProductController(IProductCatalogRepository productCatalogRepository)
 {
     _productCatalogRepository = productCatalogRepository;
 }
 public ProductCatalogService(IProductCatalogRepository repository)
 {
     _repository = repository;
 }
Exemple #26
0
 public SearchResultsPageViewModel(IProductCatalogRepository productCatalogRepository, IResourceLoader resourceLoader, IAlertMessageService alertMessageService)
 {
     _productCatalogRepository = productCatalogRepository;
     _resourceLoader           = resourceLoader;
     _alertMessageService      = alertMessageService;
 }
Exemple #27
0
 public CreateProductCatalogHandler(IProductCatalogRepository productCatalogRepository, IMediator mediator)
 {
     _productCatalogRepository = productCatalogRepository;
     _mediator = mediator;
 }