public ActionResult MoveMetaWidget(MetaWidgetMoveModel model) { ViewBag.MenuItem = CurrentMenuItem; var metaWidget = _unitOfWork.Repository <MetaWidget>() .Queryable() .Include(mw => mw.MetaPage) .Include(mw2 => mw2.WidgetType) .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) { metaWidget.MetaPage = _unitOfWork.Repository <MetaPage>().Queryable().Single(mp => mp.Id == model.DestinationPageId); _unitOfWork.Repository <MetaWidget>().Update(metaWidget); _unitOfWork.Complete(); HttpCookie cookie = new HttpCookie("PopUpMessage"); cookie.Value = "Widget moved successfully"; Response.Cookies.Add(cookie); return(Redirect(returnUrl)); } } var pages = new List <SelectListItem> { { new SelectListItem { Value = "", Text = "" } } }; pages.AddRange(_unitOfWork.Repository <MetaPage>() .Queryable() .Where(c => c.Id != metaWidget.MetaPage.Id) .OrderBy(c => c.PageName) .Select(c => new SelectListItem { Value = c.Id.ToString(), Text = c.PageName }) .ToArray()); ViewBag.DestinationPages = pages; return(View(model)); }
public ActionResult MoveMetaWidget(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 MetaWidgetMoveModel { MetaWidgetId = metaWidget.Id, WidgetName = metaWidget.WidgetName, CurrentPageName = metaWidget.MetaPage.PageName }; var pages = new List <SelectListItem>(); pages.AddRange(_unitOfWork.Repository <MetaPage>() .Queryable() .Where(c => c.Id != metaWidget.MetaPage.Id) .OrderBy(c => c.PageName) .Select(c => new SelectListItem { Value = c.Id.ToString(), Text = c.PageName }) .ToArray()); ViewBag.DestinationPages = pages; return(View(model)); }