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)); }
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)); }