public ActionResult DeleteMetaWidget(MetaWidgetDeleteModel model) { ViewBag.MenuItem = CurrentMenuItem; var metaWidget = _unitOfWork.Repository <MetaWidget>() .Queryable() .Include(mw => mw.MetaPage) .SingleOrDefault(p => p.Id == model.MetaWidgetId); ViewBag.ReturnUrl = "/Publisher/PageViewer.aspx?guid=" + metaWidget.MetaPage.metapage_guid; if (metaWidget != null) { var returnUrl = "/Publisher/PageViewer.aspx?guid=" + metaWidget.MetaPage.metapage_guid.ToString(); if (ModelState.IsValid) { _unitOfWork.Repository <MetaWidget>().Delete(metaWidget); _unitOfWork.Complete(); HttpCookie cookie = new HttpCookie("PopUpMessage"); cookie.Value = "Widget deleted successfully"; Response.Cookies.Add(cookie); return(Redirect(returnUrl)); } } return(View(model)); }
public ActionResult DeleteMetaWidget(int metaWidgetId) { ViewBag.MenuItem = CurrentMenuItem; var metaWidget = _unitOfWork.Repository <MetaWidget>() .Queryable() .Include(mw => mw.MetaPage) .SingleOrDefault(p => p.Id == metaWidgetId); ViewBag.ReturnUrl = "/Publisher/PageViewer.aspx?guid=" + metaWidget.MetaPage.metapage_guid; if (metaWidget == null) { ViewBag.Entity = "Meta Widget"; return(View("NotFound")); } // Prepare model var model = new MetaWidgetDeleteModel { MetaWidgetId = metaWidget.Id, PageName = metaWidget.MetaPage.PageName, WidgetName = metaWidget.WidgetName, WidgetType = metaWidget.WidgetType.Description }; return(View(model)); }