Esempio n. 1
0
        public async Task OnGet(CatalogIndexViewModel catalogModel, int?pageId)
        {
            var cacheKey = CacheHelpers.GenerateCatalogItemCacheKey(pageId.GetValueOrDefault(), ApplicationConstants.ITEMS_PER_PAGE, catalogModel.brandFilterApplied, catalogModel.typeFilterApplied);

            _cache.Remove(cacheKey);
            CatalogModel = await _catalogViewModelService.GetCatalogItems(pageId.GetValueOrDefault(), ApplicationConstants.ITEMS_PER_PAGE, catalogModel.brandFilterApplied, catalogModel.typeFilterApplied);
        }
Esempio n. 2
0
        public async Task OnGet(CatalogIndexViewModel catalogModel, int?pageId)
        {
            CatalogModel = await _catalogViewModelService.GetCatalogItems(pageId ?? 0, Constants.ITEMS_PER_PAGE, catalogModel.BrandFilterApplied, catalogModel.TypesFilterApplied);

            try
            {
                var bannersResult = await _config["Empay:BannerEndpointUrl"]
                                    .PostJsonAsync(new
                {
                    txn_id  = "14",
                    ad_type = "banner"
                })
                                    .ReceiveJson <BannerViewModel>()
                                    .ConfigureAwait(false);

                if (bannersResult != null && bannersResult.status == "success")
                {
                    CatalogModel.Ads = bannersResult.results;
                }
            }
            catch (Exception)
            {
                // TODO: log
            }
        }
Esempio n. 3
0
        public async Task <IActionResult> List(int?brandFilterApplied, int?typesFilterApplied, int?page)
        {
            int itemsPage    = typesFilterApplied.HasValue ? (await _typeRepository.ListAllAsync()).Single(x => x.Id == typesFilterApplied).ItemsToDisplay : 10;
            var catalogModel = await _catalogViewModelService.GetCatalogItems(page ?? 0, itemsPage, brandFilterApplied, typesFilterApplied);

            return(Ok(catalogModel));
        }
        public async Task <IActionResult> List(int?brandFilterApplied, int?typesFilterApplied, int?page)
        {
            var itemsPerPage = 10;
            var catalogModel = await _catalogViewModelService.GetCatalogItems(page ?? 0, itemsPerPage, brandFilterApplied, typesFilterApplied);

            // (page ?? 0): if page var not provided replace with 0
            return(Ok(catalogModel));
        }
Esempio n. 5
0
        public async Task OnGet(CatalogIndexViewModel catalogModel, int?pageId)
        {
            var culture  = CultureInfo.CurrentCulture.Name;
            var cacheKey = CacheHelpers.GenerateCatalogItemCacheKey(pageId.GetValueOrDefault(), Constants.ITEMS_PER_PAGE, culture, catalogModel.BrandFilterApplied, catalogModel.TypesFilterApplied);

            _cache.Remove(cacheKey);

            CatalogModel = await _catalogViewModelService.GetCatalogItems(pageId.GetValueOrDefault(), Constants.ITEMS_PER_PAGE, catalogModel.BrandFilterApplied, catalogModel.TypesFilterApplied);
        }
Esempio n. 6
0
 public async Task OnGet(CatalogIndexViewModel catalogModel, int?pageId)
 {
     CatalogModel = await _catalogViewModelService.GetCatalogItems(
         pageId ?? 0,
         Constants.ITEMS_PER_PAGE,
         catalogModel.BrandFilterApplied,
         catalogModel.TypesFilterApplied,
         catalogModel.SearchText);
 }
Esempio n. 7
0
        public async Task <FileResult> RenderAsync()
        {
            var catalogPageModel = new CatalogPageFiltersViewModel()
            {
                Culture      = CultureInfo.CurrentCulture.Name,
                ItemsPerPage = 0
            };
            var catalogModel = await _catalogViewModelService.GetCatalogItems(catalogPageModel, false, true);

            var cc = catalogModel.CatalogItems.FirstOrDefault();

            var html = await _viewRenderService.RenderToStringAsync("Pdf/Catalog", cc);

            var htmlToPdf = new HtmlToPdf();
            var pdf       = await htmlToPdf.RenderHtmlAsPdfAsync(html);

            return(File(pdf.BinaryData, "application/pdf;", "Catalog.pdf"));
        }
        public async Task OnGet(CatalogIndexViewModel catalogModel, int?pageId, int?deleteId)
        {
            CatalogModel = await _catalogViewModelService.GetCatalogItems(pageId ?? 0, Constants.ITEMS_PER_PAGE, catalogModel.BrandFilterApplied, catalogModel.TypesFilterApplied);

            if (deleteId != null)
            {
                await _catalogViewModelService.DeleteCatalogItem(catalogModel.CatalogItems.Where(x => x.Id == deleteId).SingleOrDefault());
            }
        }
Esempio n. 9
0
 public async Task OnGet(CatalogIndexViewModel catalogModel, int?pageId)
 {
     CatalogModel = await _catalogViewModelService.GetCatalogItems(
         pageId ?? 0, 1000,
         catalogModel.SearchFilter,
         catalogModel.BrandFilterApplied, catalogModel.TypesFilterApplied,
         convertPrice : true,
         HttpContext.RequestAborted);
 }
Esempio n. 10
0
        public async Task <CatalogIndexViewModel> GetCatalogItems(int pageIndex, int itemsPage, int?brandId, int?typeId)
        {
            var cacheKey = CacheHelpers.GenerateCatalogItemCacheKey(pageIndex, Constants.ITEMS_PER_PAGE, brandId, typeId);

            return(await _cache.GetOrCreateAsync(cacheKey, async entry =>
            {
                entry.SlidingExpiration = CacheHelpers.DefaultCacheDuration;
                return await _catalogViewModelService.GetCatalogItems(pageIndex, itemsPage, brandId, typeId);
            }));
        }
Esempio n. 11
0
        public async Task OnGet(CatalogIndexViewModel catalogModel, int?pageId)
        {
            CatalogModel = await _catalogViewModelService.GetCatalogItems(pageId ?? 0, Constants.ITEMS_PER_PAGE, catalogModel.BrandFilterApplied, catalogModel.TypesFilterApplied, HttpContext.RequestAborted);

            CatalogModel.ResultView  = catalogModel.ResultView; // HACK
            CatalogModel.ResultViews = Enum <ResultView> .GetAll()
                                       .Select(resultView => new SelectListItem {
                Value = resultView.ToString(), Text = resultView.ToString()
            });
        }
Esempio n. 12
0
        public async Task OnGet(CatalogPageFiltersViewModel catalogPageModel, string culture)//CatalogIndexViewModel catalogModel
        {
            catalogPageModel.ItemsPerPage = 0;
            catalogPageModel.PageId       = 0;

            if (!string.IsNullOrEmpty(culture))
            {
                catalogPageModel.Culture = culture;
            }

            CatalogModel = await _catalogViewModelService.GetCatalogItems(catalogPageModel, false, true);

            CatalogPageModel = catalogPageModel;
        }
Esempio n. 13
0
        public async Task OnGet(CatalogIndexViewModel catalogModel, int?pageId, bool convertPrice = true)
        {
            var cacheKey = CacheHelpers.GenerateCatalogItemCacheKey(pageId.GetValueOrDefault(), Constants.ITEMS_PER_PAGE, catalogModel.SearchFilter, catalogModel.BrandFilterApplied, catalogModel.TypesFilterApplied, CultureInfo.CurrentCulture.Name);

            _cache.Remove(cacheKey);

            CatalogModel = await _catalogViewModelService.GetCatalogItems(pageId.GetValueOrDefault(), Constants.ITEMS_PER_PAGE, catalogModel.SearchFilter, catalogModel.BrandFilterApplied, catalogModel.TypesFilterApplied, convertPrice : false, HttpContext.RequestAborted);

            CatalogModel.ResultView  = catalogModel.ResultView; // HACK
            CatalogModel.ResultViews = Enum <ResultView> .GetAll()
                                       .Select(resultView => new SelectListItem {
                Value = resultView.ToString(), Text = resultView.ToString()
            });
        }
Esempio n. 14
0
        public async Task OnGet(CatalogIndexViewModel catalogModel, int?pageId)
        {
            var cacheKey = CacheHelpers.GenerateCatalogItemCacheKey(
                pageId.GetValueOrDefault(),
                Constants.ITEMS_PER_PAGE,
                catalogModel.SearchText,
                catalogModel.BrandFilterApplied,
                catalogModel.TypesFilterApplied);

            _cache.Remove(cacheKey);

            CatalogModel = await _catalogViewModelService.GetCatalogItems(
                pageId.GetValueOrDefault(),
                Constants.ITEMS_PER_PAGE,
                catalogModel.SearchText,
                catalogModel.BrandFilterApplied,
                catalogModel.TypesFilterApplied,
                convertPrice : false,
                HttpContext.RequestAborted);
        }
Esempio n. 15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="catalogPageModel">User catalog filters</param>
        /// <param name="icf">if changed any filters</param>
        /// <param name="culture">parse culture information</param>
        /// <returns></returns>
        public async Task OnGet(CatalogPageFiltersViewModel catalogPageModel, bool icf, string culture)//CatalogIndexViewModel catalogModel
        {
            // Para o caso de o pedido de busca por termo estiver fora da pagina inicial
            if (0 < catalogPageModel.PageId && icf)
            {
                catalogPageModel.PageId = 0;
            }
            if (!string.IsNullOrEmpty(culture))
            {
                catalogPageModel.Culture = culture;
            }

            CatalogModel = await _catalogViewModelService.GetCatalogItems(catalogPageModel, true, true);

            CatalogPageModel = catalogPageModel;

            CatalogModel.OrdersBy = Enum <NamesOrderBy> .GetAll().Select(orderBy => new SelectListItem {
                Value = orderBy.ToString(), Text = orderBy.ToString()
            });

            CatalogModel.Orders = Enum <Ordination> .GetAll().Select(order => new SelectListItem {
                Value = order.ToString(), Text = order.ToString()
            });
        }
Esempio n. 16
0
 public async Task OnGet(CatalogIndexViewModel catalogModel, int?pageId)
 {
     CatalogModel = await _catalogViewModelService.GetCatalogItems(pageId ?? 0, ApplicationConstants.ITEMS_PER_PAGE, catalogModel.brandFilterApplied, catalogModel.typeFilterApplied);
 }
Esempio n. 17
0
        public async Task OnGet(CatalogPageFiltersViewModel catalogPageModel, int?pageId)
        {
            CatalogModel = await _catalogViewModelService.GetCatalogItems(catalogPageModel, false, false);

            CatalogPageModel = catalogPageModel;
        }
Esempio n. 18
0
        public async Task OnGet(CatalogIndexViewModel catalogModel, int?pageId)
        {
            int itemsPage = catalogModel.TypesFilterApplied.HasValue ? (await typeRepository.ListAllAsync()).Single(x => x.Id == catalogModel.TypesFilterApplied).ItemsToDisplay : 10;

            CatalogModel = await _catalogViewModelService.GetCatalogItems(pageId ?? 0, itemsPage, catalogModel.BrandFilterApplied, catalogModel.TypesFilterApplied);
        }