Exemple #1
0
            /// <summary>
            /// Gets the card types.
            /// </summary>
            /// <param name="queryResultSettings">The query result settings.</param>
            /// <returns>A response containing collection of card types supported by channel..</returns>
            public async Task <ActionResult> GetCardTypes(QueryResultSettings queryResultSettings)
            {
                EcommerceContext           ecommerceContext         = ServiceUtilities.GetEcommerceContext(this.HttpContext);
                OrgUnitOperationsHandler   orgUnitOperationsHandler = new OrgUnitOperationsHandler(ecommerceContext);
                PagedResult <CardTypeInfo> cardTypeInfoCollection   = await orgUnitOperationsHandler.GetCardTypes(queryResultSettings);

                return(this.Json(cardTypeInfoCollection.Results));
            }
Exemple #2
0
            /// <summary>
            /// Gets the channel tender types.
            /// </summary>
            /// <param name="queryResultSettings">The query result settings.</param>
            /// <returns>Tender types response.</returns>
            public async Task <ActionResult> GetChannelTenderTypes(QueryResultSettings queryResultSettings)
            {
                EcommerceContext         ecommerceContext         = ServiceUtilities.GetEcommerceContext(this.HttpContext);
                OrgUnitOperationsHandler orgUnitOperationsHandler = new OrgUnitOperationsHandler(ecommerceContext);
                PagedResult <TenderType> tenderTypes = await orgUnitOperationsHandler.GetTenderTypes(queryResultSettings);

                return(this.Json(tenderTypes.Results));
            }
Exemple #3
0
            /// <summary>
            /// Gets the channel configuration.
            /// </summary>
            /// <returns>Response containing the channel configuration.</returns>
            public async Task <ActionResult> GetChannelConfiguration()
            {
                EcommerceContext         ecommerceContext         = ServiceUtilities.GetEcommerceContext(this.HttpContext);
                OrgUnitOperationsHandler orgUnitOperationsHandler = new OrgUnitOperationsHandler(ecommerceContext);
                ChannelConfiguration     channelConfiguration     = await orgUnitOperationsHandler.GetChannelConfiguration();

                return(this.Json(channelConfiguration));
            }
Exemple #4
0
            /// <summary>
            /// Gets the nearby stores.
            /// </summary>
            /// <param name="latitude">The latitude.</param>
            /// <param name="longitude">The longitude.</param>
            /// <param name="distance">The distance.</param>
            /// <param name="queryResultSettings">The query result settings.</param>
            /// <returns>Response containing nearby stores.</returns>
            public async Task <ActionResult> GetNearbyStores(decimal latitude, decimal longitude, int distance, QueryResultSettings queryResultSettings)
            {
                EcommerceContext              ecommerceContext         = ServiceUtilities.GetEcommerceContext(this.HttpContext);
                OrgUnitOperationsHandler      orgUnitOperationsHandler = new OrgUnitOperationsHandler(ecommerceContext);
                PagedResult <OrgUnitLocation> orgUnitLocations         = await orgUnitOperationsHandler.GetNearbyStores(latitude, longitude, distance, queryResultSettings);

                return(this.Json(orgUnitLocations.Results));
            }
Exemple #5
0
            /// <summary>
            /// Gets the nearby stores with availability.
            /// </summary>
            /// <param name="latitude">The latitude.</param>
            /// <param name="longitude">The longitude.</param>
            /// <param name="searchRadius">The search radius.</param>
            /// <param name="itemUnits">The item units.</param>
            /// <param name="queryResultSettings">The query result settings.</param>
            /// <returns>Response containing stores with product availability.</returns>
            public async Task <ActionResult> GetNearbyStoresWithAvailability(decimal latitude, decimal longitude, double searchRadius, IEnumerable <ItemUnit> itemUnits, QueryResultSettings queryResultSettings)
            {
                EcommerceContext                  ecommerceContext         = ServiceUtilities.GetEcommerceContext(this.HttpContext);
                OrgUnitOperationsHandler          orgUnitOperationsHandler = new OrgUnitOperationsHandler(ecommerceContext);
                PagedResult <OrgUnitAvailability> orgUnitAvailabilities    = await orgUnitOperationsHandler.GetNearbyStoresWithAvailability(latitude, longitude, searchRadius, itemUnits, queryResultSettings);

                return(this.Json(orgUnitAvailabilities.Results));
            }
Exemple #6
0
            /// <summary>
            /// Gets the delivery options information.
            /// </summary>
            /// <param name="queryResultSettings">The query result settings.</param>
            /// <returns>Response containing delivery options available for the channel.</returns>
            public async Task <ActionResult> GetDeliveryOptionsInfo(QueryResultSettings queryResultSettings)
            {
                EcommerceContext             ecommerceContext         = ServiceUtilities.GetEcommerceContext(this.HttpContext);
                OrgUnitOperationsHandler     orgUnitOperationsHandler = new OrgUnitOperationsHandler(ecommerceContext);
                PagedResult <DeliveryOption> deliveryOptions          = await orgUnitOperationsHandler.GetDeliveryOptionsInfo(queryResultSettings);

                return(this.Json(deliveryOptions.Results));
            }
Exemple #7
0
            /// <summary>
            /// Return View.
            /// </summary>
            /// <returns>The View.</returns>
            public async Task <ActionResult> Index()
            {
                EcommerceContext         ecommerceContext         = ServiceUtilities.GetEcommerceContext(this.HttpContext);
                OrgUnitOperationsHandler orgUnitOperationsHandler = new OrgUnitOperationsHandler(ecommerceContext);

                PagedResult <Category> categories = await orgUnitOperationsHandler.GetNavigationalHierarchyCategories(Utilities.DefaultQuerySettings);

                IEnumerable <long> rawCategoryIds = categories.Select(c => c.RecordId);

                Collection <Product> productList = null;

                // add productId to an ObservableCollection
                ObservableCollection <long> productIds = new ObservableCollection <long>()
                {
                    22565423115, 22565423455, 22565423885, 22565423933
                };

                ProductSearchCriteria searchCriteria = new ProductSearchCriteria
                {
                    DataLevelValue = 4,
                    Ids            = productIds
                };

                // try and get product information
                ProductOperationsHandler productOperationsHandler = new ProductOperationsHandler(ecommerceContext);

                // This will fetch even uncatalogued products that match the criteria.
                PagedResult <Product> products = await productOperationsHandler.SearchProducts(searchCriteria, new long[] { 0 }, Utilities.DefaultQuerySettings);

                if (products.Results.Any())
                {
                    productList = new Collection <Product>(products.Results.ToList());
                }

                return(this.View(HomeController.HomeViewName, productList));
            }
Exemple #8
0
            /// <summary>
            /// Get the Details for a particular product.
            /// </summary>
            /// <param name="productId">The product id you need the details for.</param>
            /// <returns>The View for that product.</returns>
            public async Task <ActionResult> Index(string productId = "")
            {
                EcommerceContext         ecommerceContext         = ServiceUtilities.GetEcommerceContext(this.HttpContext);
                OrgUnitOperationsHandler orgUnitOperationsHandler = new OrgUnitOperationsHandler(ecommerceContext);

                PagedResult <Category> categories = await orgUnitOperationsHandler.GetNavigationalHierarchyCategories(Utilities.DefaultQuerySettings);

                IEnumerable <long> rawCategoryIds = categories.Select(c => c.RecordId);

                ObservableCollection <long> productIds = null;
                Product prod = null;
                Collection <CustomLink> breadcrumbNavLinks = new Collection <CustomLink>();
                long productIdentifier;

                if (string.IsNullOrEmpty(productId) || !long.TryParse(productId, out productIdentifier))
                {
                    RetailLogger.Log.OnlineStoreInvalidProductIdProvided(productId);
                    return(this.RedirectToAction(HomeController.DefaultActionName, HomeController.ControllerName));
                }
                else
                {
                    // add productId to an ObservableCollection
                    productIds = new ObservableCollection <long>();
                    productIds.Add(productIdentifier);

                    ProductSearchCriteria searchCriteria = new ProductSearchCriteria
                    {
                        DataLevelValue = 4,
                        Ids            = productIds
                    };

                    // try and get product information
                    ProductOperationsHandler     productOperationsHandler = new ProductOperationsHandler(ecommerceContext);
                    PagedResult <ProductCatalog> productCatalogs          = await productOperationsHandler.GetProductCatalogs(Utilities.DefaultQuerySettings);

                    IEnumerable <long> activeCatalogIds = productCatalogs.Results.Select(pc => pc.RecordId);

                    PagedResult <Product> products = await productOperationsHandler.SearchProducts(searchCriteria, activeCatalogIds, Utilities.DefaultQuerySettings);

                    if (!products.Results.Any())
                    {
                        var message = string.Format("ProductIds: {0}.", string.Join(",", productIds));
                        RetailLogger.Log.OnlineStoreNoProductsFound(message);
                        return(this.RedirectToAction(HomeController.DefaultActionName, HomeController.ControllerName));
                    }

                    prod = products.Results.First <Product>();

                    // Breadcrumb Navigation Links
                    // add current item
                    breadcrumbNavLinks.Add(new CustomLink("/ProductDetails?productId=" + prod.RecordId, prod.ProductName));

                    Category currentCategory = this.GetCategoryById(prod.CategoryIds.First(), categories);

                    while (currentCategory.ParentCategory != 0)
                    {
                        breadcrumbNavLinks.Add(new CustomLink("/ProductGallery?categoryId=" + currentCategory.RecordId, currentCategory.Name));
                        currentCategory = this.GetCategoryById(currentCategory.ParentCategory, categories);
                    }

                    breadcrumbNavLinks.Add(new CustomLink("/", "Home"));
                }

                prod = (await ProductDetailsController.PopulateViewSpecificProductInfo(new Product[] { prod }, ecommerceContext)).FirstOrDefault();

                return(this.View(ProductDetailsController.ProductDetailsViewName, new ProductDetailsModel(prod, breadcrumbNavLinks)));
            }
            /// <summary>
            /// Return View with optional search criteria added.
            /// </summary>
            /// <param name="categoryId">Required: Category id to show products for.</param>
            /// <param name="filterBrands">List of brands to show (comma separated).</param>
            /// <param name="filterCategories">List of categories to show (comma separated).</param>
            /// <returns>View of Products.</returns>
            public async Task <ActionResult> Index(string categoryId = "", string[] filterBrands = null, string[] filterCategories = null)
            {
                EcommerceContext         ecommerceContext         = ServiceUtilities.GetEcommerceContext(this.HttpContext);
                OrgUnitOperationsHandler orgUnitOperationsHandler = new OrgUnitOperationsHandler(ecommerceContext);

                PagedResult <Category> categories = await orgUnitOperationsHandler.GetNavigationalHierarchyCategories(Utilities.DefaultQuerySettings);

                IEnumerable <long> rawCategoryIds = categories.Select(c => c.RecordId);

                // determine what category to load products for, if null, load all products
                ObservableCollection <long> categoryIds;

                if (string.IsNullOrEmpty(categoryId))
                {
                    categoryIds = new ObservableCollection <long>(rawCategoryIds);
                }
                else
                {
                    categoryIds = new ObservableCollection <long>();
                    categoryIds.Add(long.Parse(categoryId));
                }

                // Category Id to Name Mapping
                Dictionary <long, string> mapping = new Dictionary <long, string>();

                foreach (Category category in categories)
                {
                    mapping.Add(category.RecordId, category.Name);
                }

                // Retrieving Products - make sure we include products from descendant categories too
                ProductSearchCriteria searchCriteria = new ProductSearchCriteria
                {
                    DataLevelValue = 4,
                    CategoryIds    = categoryIds,
                    IncludeProductsFromDescendantCategories = true
                };

                // try and get product information
                ProductOperationsHandler productOperationsHandler = new ProductOperationsHandler(ecommerceContext);

                PagedResult <ProductCatalog> productCatalogs = await productOperationsHandler.GetProductCatalogs(Utilities.DefaultQuerySettings);

                IEnumerable <long> activeCatalogIds = productCatalogs.Results.Select(pc => pc.RecordId);

                PagedResult <Product> products = await productOperationsHandler.SearchProducts(searchCriteria, activeCatalogIds, Utilities.DefaultQuerySettings);

                // Breadcrumb Navigation Links
                Collection <CustomLink> breadcrumbNavLinks = new Collection <CustomLink>();
                Category currentCategory = this.GetCategoryById(long.Parse(categoryId), categories);

                while (!currentCategory.ParentCategory.Equals((long?)0))
                {
                    breadcrumbNavLinks.Add(new CustomLink("/ProductGallery?categoryId=" + currentCategory.RecordId, currentCategory.Name));
                    currentCategory = this.GetCategoryById(currentCategory.ParentCategory, categories);
                }

                breadcrumbNavLinks.Add(new CustomLink("/", "Home"));

                // Filter Mapping
                Dictionary <string, string[]> filters = new Dictionary <string, string[]>();

                filters.Add("brand", filterBrands);
                filters.Add("categories", filterCategories);

                IEnumerable <Product> productList = await ProductDetailsController.PopulateViewSpecificProductInfo(products.Results, ecommerceContext);

                // create a new product gallery model for the view
                ProductGalleryModel productGalleryModel = new ProductGalleryModel(long.Parse(categoryId), productList, breadcrumbNavLinks, mapping, filters);

                return(this.View(ProductGalleryController.ProductGalleryViewName, productGalleryModel));
            }