Example #1
0
        public ActionResult Create(AdsBannerModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets))
            {
                return(AccessDeniedView());
            }
            if (ModelState.IsValid)
            {
                var adsbanner = model.ToEntity();
                if (model.FromDate != null)
                {
                    adsbanner.FromDateUtc = _dateTimeHelper.ConvertToUtcTime(model.FromDate.Value);
                }
                if (model.ToDate != null)
                {
                    adsbanner.ToDateUtc = _dateTimeHelper.ConvertToUtcTime(model.ToDate.Value);
                }

                _adsBannerService.InsertAdsBanner(adsbanner);

                UpdatePictureSeoNames(model);

                SuccessNotification(_localizationService.GetResource("Plugins.Widgets.AdsBanner.Added"));
                return(continueEditing
                    ? RedirectToAction("Edit", new { id = adsbanner.Id })
                    : RedirectToAction("ConfigureWidget", "Widget",
                                       new { area = "Admin", systemName = "Widgets.AdsBanner" }));
            }


            PrepareAdsBannerModel(model);
            return(View("~/Plugins/Widgets.AdsBanner/Views/WidgetsAdsBanner/Create.cshtml", model));
        }
Example #2
0
 public void PrepareAdsBannerModel(AdsBannerModel model)
 {
     model.AvailableWidgetZones = _widgetService.LoaddAllWidgetZones().Select(q => new SelectListItem
     {
         Text  = q.Name,
         Value = q.Id.ToString()
     }).ToList();
 }
Example #3
0
        protected virtual void UpdatePictureSeoNames(AdsBannerModel adsBanner)
        {
            var picture = _pictureService.GetPictureById(adsBanner.PictureId);

            if (picture != null)
            {
                _pictureService.SetSeoFilename(picture.Id, _pictureService.GetPictureSeName(adsBanner.Name));
            }
        }
Example #4
0
        public ActionResult Create()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets))
            {
                return(AccessDeniedView());
            }
            var model = new AdsBannerModel();

            PrepareAdsBannerModel(model);
            return(View("~/Plugins/Widgets.AdsBanner/Views/WidgetsAdsBanner/Create.cshtml", model));
        }
Example #5
0
        public ActionResult Edit(AdsBannerModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets))
            {
                return(AccessDeniedView());
            }
            var adsbanner = _adsBannerService.GetById(model.Id);

            if (adsbanner == null)
            {
                return(RedirectToAction("ConfigureWidget", "Widget",
                                        new { area = "Admin", systemName = "Widgets.AdsBanner" }));
            }
            if (ModelState.IsValid)
            {
                adsbanner = model.ToEntity(adsbanner);

                var prevPictureId = adsbanner.PictureId;

                _adsBannerService.UpdateAdsBanner(adsbanner);
                //delete an old picture (if deleted or updated)
                if (prevPictureId > 0 && prevPictureId != adsbanner.PictureId)
                {
                    var prevPicture = _pictureService.GetPictureById(prevPictureId);
                    if (prevPicture != null)
                    {
                        _pictureService.DeletePicture(prevPicture);
                    }
                }
                SuccessNotification(_localizationService.GetResource("Plugins.Widgets.AdsBanner.Updated"));
                return(continueEditing
                    ? RedirectToAction("Edit", new { id = adsbanner.Id })
                    : RedirectToAction("ConfigureWidget", "Widget",
                                       new { area = "Admin", systemName = "Widgets.AdsBanner" }));
            }

            PrepareAdsBannerModel(model);

            return(View("~/Plugins/Widgets.AdsBanner/Views/WidgetsAdsBanner/Edit.cshtml", model));
        }
Example #6
0
 public static AdsBannerRecord ToEntity(this AdsBannerModel model, AdsBannerRecord destination)
 {
     return(model.MapTo(destination));
 }
Example #7
0
 public static AdsBannerRecord ToEntity(this AdsBannerModel model)
 {
     return(model.MapTo <AdsBannerModel, AdsBannerRecord>());
 }