Beispiel #1
0
        public ActionResult Index()
        {
            IList <Banner> banners;

            if (_workContext.CurrentCustomer.IsRegistered())
            {
                banners = _bannerService.GetAllBanners()
                          .Where(x => x.DisplayOnMain).ToList();
            }
            else
            {
                banners = _bannerService.GetAllBanners()
                          .Where(x => x.DisplayOnMain).ToList();
            }
            var model = banners.Select(x => new BannerModel()
            {
                AltText    = x.Alt,
                BannerType = x.BannerType,
                TitleText  = x.Title,
                Url        = x.Url,
                ImageUrl   = _pictureService.GetPictureUrl(x.PictureId, showDefaultPicture: false)
            }).ToList();

            return(View(model));
        }
        public IActionResult List(DataSourceRequest command)
        {
            var banners   = _bannerService.GetAllBanners();
            var gridModel = new DataSourceResult
            {
                Data = banners.Select(x =>
                {
                    var model  = x.ToModel();
                    model.Body = "";
                    return(model);
                }),
                Total = banners.Count
            };

            return(Json(gridModel));
        }
Beispiel #3
0
        public ActionResult List()
        {
            int languageId      = _workContext.WorkingLanguage.Id;
            var homePageBanners = _bannerService.GetAllBanners()
                                  .Select(x =>
            {
                var model           = new BannerModel();
                model.Url           = x.Url;
                model.Title         = x.Title;
                model.Alt           = x.Alt;
                model.PictureId     = x.PictureId;
                model.Id            = x.Id;
                model.NetBanner     = x.NetBanner;
                model.Size          = GetBannerWidth(x.BannerType);
                model.DisplayOnMain = x.DisplayOnMain;
                model.Height        = GetBannerHeight(x.BannerType);
                model.BannerType    = x.BannerType;
                if (x.BannerType == BannerTypeEnum.Productpage)
                {
                    var category       = _categoryService.GetCategoryById(x.CategoryId.Value);
                    model.CategoryName = category.Name;
                    model.CategoryId   = category.Id;
                }
                model.BannerTypeId     = x.BannerTypeId;
                model.BannerTypeString = x.BannerType.GetLocalizedEnum(_localizationService, _workContext.WorkingLanguage.Id);
                return(model);
            })
                                  .Select(x =>
            {
                x.PictureModel = new PictureModel()
                {
                    ImageUrl         = _pictureService.GetPictureUrl(x.PictureId, x.Size),
                    FullSizeImageUrl = _pictureService.GetPictureUrl(x.PictureId)
                };
                return(x);
            })
                                  .ToList();

            var viewModel = new BannerListModel()
            {
                HomePageBanners = homePageBanners
            };

            return(View(viewModel));
        }
Beispiel #4
0
        public ActionResult List(EventPagingModel pageModel)
        {
            pageModel.PageSize = int.Parse(_settingsService.GetSettingByKey("event.eventsnumber").Value);
            var events = _eventService.GetAllEvents()
                         .Where(x => (x.EndDate.HasValue && x.EndDate.Value.Date >= DateTime.UtcNow.Date) || (!x.EndDate.HasValue && x.StartDate.Date >= DateTime.UtcNow.Date))
                         .OrderBy(x => x.StartDate);
            int pictureSize = _mediaSettings.EventThumbNailImageSize;
            var model       = events.Select(x => x.ToModel(_workContext.WorkingLanguage.Id))
                              .Where(x => x.Title != null && x.ShortDescription != null && x.FullDescription != null)
                              .Select(x =>
            {
                x.PictureModel = new PictureModel()
                {
                    FullSizeImageUrl = _pictureService.GetPictureUrl(x.PictureId),
                    ImageUrl         = _pictureService.GetPictureUrl(x.PictureId, pictureSize, showDefaultPicture: false)
                };
                x.CatalogPictureModel = new PictureModel()
                {
                    FullSizeImageUrl = _pictureService.GetPictureUrl(x.CatalogPictureid),
                    ImageUrl         = _pictureService.GetPictureUrl(x.CatalogPictureid, pictureSize, showDefaultPicture: false)
                };
                return(x);
            });
            IPagedList <EventInfoModel> modeList = new PagedList <EventInfoModel>(model.ToList(), pageModel.PageIndex, pageModel.PageSize);

            pageModel.LoadPagedList(modeList);

            var resultModel = new EventNavigationModel()
            {
                PagingContext = pageModel,
                EventList     = modeList
            };

            resultModel.Banners = _bannerService.GetAllBanners().Where(x => !x.DisplayOnMain)
                                  .Select(x => new BannerModel()
            {
                BannerType = x.BannerType,
                TitleText  = x.Title,
                AltText    = x.Alt,
                Url        = x.Url,
                ImageUrl   = _pictureService.GetPictureUrl(x.PictureId)
            }).ToList();
            return(View(resultModel));
        }
Beispiel #5
0
        public ActionResult TopicDetails(string systemName)
        {
            var cacheKey   = string.Format(ModelCacheEventConsumer.TOPIC_MODEL_KEY, systemName, _workContext.WorkingLanguage.Id);
            var cacheModel = _cacheManager.Get(cacheKey, () => PrepareTopicModel(systemName));

            if (cacheModel == null)
            {
                return(RedirectToRoute("HomePage"));
            }
            cacheModel.Banners = _bannerService.GetAllBanners().Where(x => !x.DisplayOnMain).Select(x => new BannerModel()
            {
                BannerType = x.BannerType,
                AltText    = x.Alt,
                TitleText  = x.Title,
                Url        = x.Url,
                ImageUrl   = _pictureService.GetPictureUrl(x.PictureId)
            }).ToList();

            return(View("TopicDetails", cacheModel));
        }
Beispiel #6
0
        public IActionResult List(DataSourceRequest command)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageBanners))
            {
                return(AccessDeniedView());
            }

            var banners   = _bannerService.GetAllBanners();
            var gridModel = new DataSourceResult
            {
                Data = banners.Select(x =>
                {
                    var model  = x.ToModel();
                    model.Body = "";
                    return(model);
                }),
                Total = banners.Count
            };

            return(Json(gridModel));
        }
        public virtual async Task PrepareReactObjectModel(CustomerActionModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            var banners = await _bannerService.GetAllBanners();

            foreach (var item in banners)
            {
                model.Banners.Add(new SelectListItem
                {
                    Text  = item.Name,
                    Value = item.Id.ToString()
                });
            }
            var message = await _messageTemplateService.GetAllMessageTemplates("");

            foreach (var item in message)
            {
                model.MessageTemplates.Add(new SelectListItem
                {
                    Text  = item.Name,
                    Value = item.Id.ToString()
                });
            }
            var customerRole = await _customerService.GetAllCustomerRoles();

            foreach (var item in customerRole)
            {
                model.CustomerRoles.Add(new SelectListItem
                {
                    Text  = item.Name,
                    Value = item.Id.ToString()
                });
            }

            var customerTag = await _customerTagService.GetAllCustomerTags();

            foreach (var item in customerTag)
            {
                model.CustomerTags.Add(new SelectListItem
                {
                    Text  = item.Name,
                    Value = item.Id.ToString()
                });
            }

            foreach (var item in await _customerActionService.GetCustomerActionType())
            {
                model.ActionType.Add(new SelectListItem()
                {
                    Text  = item.Name,
                    Value = item.Id.ToString()
                });
            }

            foreach (var item in await _interactiveFormService.GetAllForms())
            {
                model.InteractiveForms.Add(new SelectListItem()
                {
                    Text  = item.Name,
                    Value = item.Id.ToString()
                });
            }
        }
 public ActionResult <IEnumerable <Banner> > GetAll()
 {
     return(_bannerService.GetAllBanners());
 }