public BannerModel Get(int id) { var entity = _BannerService.GetBannerById(id); var model = new BannerModel { Id = entity.Id, Title = entity.Title, ImgUrl = entity.ImgUrl, Order = entity.Order, Adduser = entity.Adduser, Addtime = entity.Addtime, Upduser = entity.Upduser, Updtime = entity.Updtime, // Content = entity.Content, }; return(model); }
public IActionResult Edit(string id) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageBanners)) { return(AccessDeniedView()); } var banner = _bannerService.GetBannerById(id); if (banner == null) { return(RedirectToAction("List")); } var model = banner.ToModel(); //locales AddLocales(_languageService, model.Locales, (locale, languageId) => { locale.Name = banner.GetLocalized(x => x.Name, languageId, false, false); locale.Body = banner.GetLocalized(x => x.Body, languageId, false, false); }); return(View(model)); }
public async Task <BannerGetResponse> GetBannerById(BannerGetRequest request) { var response = new BannerGetResponse(); try { if (string.IsNullOrEmpty(request.Id)) { response.Banner = new BannerViewModel() { Status = EnumDefine.CommonStatusEnum.New }; } else { var data = await _bannerService.GetBannerById(request.Id); if (data == null) { response.SetFail("Banner is null."); return(response); } response.Banner = data.ToModel(); } response.SetSucess(); } catch (Exception e) { response.SetFail(e); _logger.LogError(e, e.Message, request); } return(response); }
public ActionResult <Banner> GetById(int id) { var banner = _bannerService.GetBannerById(id); if (banner == null) { return(NotFound()); } return(banner); }
/// <summary> /// 新建banner视图 /// </summary> /// <returns></returns> public IActionResult AddNewBanner(int id) { Banner bannerInfo = new Banner(); if (id > 0) { bannerInfo = _bannerService.GetBannerById(id); } List <BatchInformation> batchInfos = _batchInformationService.GetAll(); ViewBag.BatchInfos = batchInfos; //ViewBag.SelectedBatchInfo = _batchInformationService.GetBatchInfoById(bannerInfo.BatchId); return(View(bannerInfo)); }
/// <summary> /// 新建banner视图 /// </summary> /// <returns></returns> public IActionResult AddNewBanner(int id) { Banner bannerInfo = new Banner(); if (id > 0) { bannerInfo = _bannerService.GetBannerById(id); } List <BatchInformation> batchInfos = _batchInformationService.GetAll(); //过滤,只有没有头图的批次才可以显示出来 var usedBatchIds = _bannerService.GetAll().Select(item => item.BatchId).Distinct().ToList(); //已经用过的批次号 var usedBatchInfos = batchInfos.Where(item => usedBatchIds.Contains(item.Id)).ToList(); var UnUsedBatchInfos = batchInfos.Except(usedBatchInfos).ToList(); ViewBag.BatchInfos = UnUsedBatchInfos; return(View(bannerInfo)); }
public async Task <ICommandResult> Handle(BannerChangeCommand mesage) { try { ICommandResult result; var rBanner = await _bannerService.GetBannerById(mesage.Id); if (rBanner == null) { result = new CommandResult() { Message = "Banner not found", ObjectId = "", Status = CommandResult.StatusEnum.Fail, ResourceName = ResourceKey.Banner_NotFound }; return(result); } RBannerItem[] rBannerItems = await _bannerService.GetBannerItemByBannerId(rBanner.Id); SystemDomains.Banner.Banner banner = new SystemDomains.Banner.Banner(rBanner, rBannerItems); banner.Change(mesage); await _bannerService.ChangeBanner(banner); await _eventSender.Notify(banner.Events); result = new CommandResult() { Message = "", ObjectId = banner.Id, Status = CommandResult.StatusEnum.Sucess }; return(result); } catch (Exception e) { e.Data["Param"] = mesage; ICommandResult result = new CommandResult() { Message = e.Message, Status = CommandResult.StatusEnum.Fail }; return(result); } }
public virtual ActionResult Edit(int id) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageBanner)) { return(AccessDeniedView()); } var banner = _bannerService.GetBannerById(id); if (banner == null) { return(RedirectToAction("List")); } var model = _bannerModelFactory.PrepareBannerModel(banner); return(View(model)); }
public IActionResult Edit(string id) { var banner = _bannerService.GetBannerById(id); if (banner == null) { return(RedirectToAction("List")); } var model = banner.ToModel(); //locales AddLocales(_languageService, model.Locales, (locale, languageId) => { locale.Name = banner.GetLocalized(x => x.Name, languageId, false, false); locale.Body = banner.GetLocalized(x => x.Body, languageId, false, false); }); return(View(model)); }
public async Task <IActionResult> Edit(string id) { var banner = await _bannerService.GetBannerById(id); if (banner == null) { return(RedirectToAction("List")); } var model = banner.ToModel(); //locales await AddLocales(_languageService, model.Locales, (locale, languageId) => { locale.Name = banner.GetTranslation(x => x.Name, languageId, false); locale.Body = banner.GetTranslation(x => x.Body, languageId, false); }); return(View(model)); }
public ActionResult BannerClick(int bannerId, string currentUrl) { var banner = _bannerService.GetBannerById(bannerId); if (banner != null) { _customerActivityService.InsertActivity("PublicStore.BannerClick", _localizationService.GetResource("ITBSFA.Banner.Click"), _workContext.CurrentCustomer, currentUrl, Request.UrlReferrer == null ? "" : Request.UrlReferrer.ToString(), bannerId, bannerId); } return(new JsonResult()); }
/// <summary> /// Single banner click report /// </summary> /// <param name="startDate">start date</param> /// <param name="endDate"> end date</param> /// <param name="stream">stream where to save results</param> /// <param name="bannerId">banner id</param> private void GenerateBannerClickReport(DateTime?startDate, DateTime?endDate, Stream stream, int bannerId) { var logType = _customerActivityService.GetActivityTypeBySystmeName("PublicStore.BannerClick"); var logs = _customerActivityService.GetAllBannerActivities(startDate, endDate, null, logType.Id, 0, 0, bannerId); ExcelPackage pck = new ExcelPackage(stream); int i = 0; var ws = pck.Workbook.Worksheets.Add("Report"); var propertis = new List <string>() { _localizationService.GetResource("ITBSFA.Admin.Banner.Id"), _localizationService.GetResource("ITBSFA.Admin.Reports.Banner.BannerType"), _localizationService.GetResource("ITBSFA.Admin.Reports.Banner.Customer"), _localizationService.GetResource("ITBSFA.Admin.Reporst.Banner.CurrenPageUrl"), _localizationService.GetResource("ITBSFA.Admin.Reporst.Banner.UrlReferrer"), _localizationService.GetResource("ITBSFA.Admin.Reports.Banner.Event"), }; ws.DefaultColWidth = Pixel2ColumnWidth(ws, 250); for (i = 0; i < propertis.Count; i++) { ws.Cells[1, i + 1].Value = propertis[i]; } int j = 2; ws.Column(6).Style.Numberformat.Format = "dd-MM-yyyy h:mm"; foreach (var bannerLog in logs) { var banner = _bannerService.GetBannerById(bannerLog.ReferenceId.Value); string bannerType = banner.BannerType.GetLocalizedEnum(_localizationService, _workContext.WorkingLanguage.Id); ws.Cells[j, 1].Value = banner.Id; ws.Cells[j, 2].Value = bannerType; ws.Cells[j, 3].Value = bannerLog.Customer == null ? "unauthorized" : bannerLog.Customer.Email; ws.Cells[j, 4].Value = bannerLog.CurrentUrl; ws.Cells[j, 5].Value = bannerLog.ReferenceUrl; ws.Cells[j, 6].Value = bannerLog.CreatedOnUtc; j++; } pck.Save(); }
public ActionResult Delete(int Id) { var banner = _bannerService.GetBannerById(Id); if (banner != null) { foreach (var lang in _languageService.GetAllLanguages()) { int pictureId = banner.GetLocalized(x => x.PictureId, lang.Id, false); if (pictureId != 0) { var picture = _pictureService.GetPictureById(pictureId); if (picture != null) { _pictureService.DeletePicture(picture); } } } _bannerService.DeleteBannner(banner); } return(RedirectToAction("List")); }
public ActionResult Edit(int?id) { PopulateBatchDropDownList(); BannerViewModel model = new BannerViewModel(); if (id != null) { Banner banner = _bannerService.GetBannerById((int)id); model = new BannerViewModel { BannerId = banner.Id, Name = banner.Name, BatchId = banner.BatchId }; } return(View(model)); }
// GET: /Admin/Banner/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var banner = _bannerService.GetBannerById(id); if (banner == null) { return(HttpNotFound()); } PopulateBannerTypesDropDownList((Portal.Infractructure.Utility.Define.BannerTypes)banner.Type); PopulateStatusDropDownList((Portal.Infractructure.Utility.Define.Status)banner.Status); return(View(banner)); }
public async Task <ICommandResult> Handle(MenuBannerMappingAddCommand message) { try { ICommandResult result; RMenu rMenu = await _menuService.Get(message.MenuId); if (rMenu == null) { result = new CommandResult() { Message = "Menu not found", ObjectId = "", Status = CommandResult.StatusEnum.Fail, ResourceName = ResourceKey.Template_NotFound }; return(result); } RBanner[] rbanners = await _bannerService.GetBannerByMenuId(rMenu.Id); Menu menu = new Menu(rMenu, rbanners); RBanner banner = await _bannerService.GetBannerById(message.BannerId); var bannerAdd = menu.AddBanner(banner); await _menuService.AddMenuBannerMapping(menu.Id, bannerAdd.Id); result = new CommandResult() { Message = "", ObjectId = menu.Id, Status = CommandResult.StatusEnum.Sucess }; return(result); } catch (Exception e) { e.Data["Param"] = message; ICommandResult result = new CommandResult() { Message = e.Message, Status = CommandResult.StatusEnum.Fail }; return(result); } }
public async Task <TemplateConfigGetResponse> GetTemplateConfigById(TemplateConfigGetRequest request) { var response = new TemplateConfigGetResponse(); try { if (string.IsNullOrEmpty(request.Id)) { response.TemplateConfig = new TemplateConfigViewModel() { Status = EnumDefine.CommonStatusEnum.New, TemplateId = request.TemplateId, }; } else { var data = await _templateService.GetTemplateConfigById(request.Id); if (data == null) { response.SetFail("TemplateConfig is null"); return(response); } KeyValueTypeStringModel componentModel = null; if (!string.IsNullOrEmpty(data.ComponentId)) { switch (data.ComponentType) { case EnumDefine.TemplateConfigComponentTypeEnum.Banner: var component = await _bannerService.GetBannerById(data.ComponentId); if (component == null) { break; } componentModel = component.ToAutocompleteModel(); break; case EnumDefine.TemplateConfigComponentTypeEnum.Menu: break; case EnumDefine.TemplateConfigComponentTypeEnum.ProductGroup: break; } } response.TemplateConfig = data.ToModel(componentModel); } if (response.TemplateConfig != null && !string.IsNullOrEmpty(response.TemplateConfig.TemplateId)) { var template = await _templateService.GetById(response.TemplateConfig.TemplateId); if (template != null && !string.IsNullOrEmpty(template.Id)) { response.Template = template.ToModel(); } } else { var template = await _templateService.GetById(request.TemplateId); if (template != null && !string.IsNullOrEmpty(template.Id)) { response.Template = template.ToModel(); } else { response.SetFail("Template not found!!!"); } } } catch (Exception e) { response.SetFail(e); _logger.LogError(e, e.Message, request); } return(response); }