Beispiel #1
0
        public ActionResult DeleteMetaPage(int metaPageId)
        {
            ViewBag.MenuItem = CurrentMenuItem;

            // Prepare clinical event
            var metaPage = _unitOfWork.Repository <MetaPage>()
                           .Queryable()
                           .SingleOrDefault(p => p.Id == metaPageId);

            ViewBag.ReturnUrl = "/Publisher/PageViewer.aspx?guid=" + metaPage.metapage_guid;

            if (metaPage == null)
            {
                ViewBag.Entity = "Meta Page";
                return(View("NotFound"));
            }

            // Prepare model
            var model = new MetaPageDeleteModel
            {
                MetaPageId = metaPage.Id,
                PageName   = metaPage.PageName
            };

            return(View(model));
        }
Beispiel #2
0
        public ActionResult DeleteMetaPage(MetaPageDeleteModel model)
        {
            ViewBag.MenuItem = CurrentMenuItem;

            var metaPage = _unitOfWork.Repository <MetaPage>()
                           .Queryable()
                           .SingleOrDefault(p => p.Id == model.MetaPageId);

            ViewBag.ReturnUrl = "/Publisher/PageViewer.aspx?guid=" + metaPage.metapage_guid;

            if (metaPage != null)
            {
                if (ModelState.IsValid)
                {
                    var pageInUse = _unitOfWork.Repository <MetaWidget>().Queryable().Any(w => w.MetaPage.Id == model.MetaPageId);

                    if (pageInUse)
                    {
                        ModelState.AddModelError("PageName", "Unable to delete the Page as it is currently in use.");
                    }
                    if (metaPage.IsSystem)
                    {
                        ModelState.AddModelError("PageName", "SYSTEM PAGE. Unable to delete.");
                    }

                    if (ModelState.IsValid)
                    {
                        _unitOfWork.Repository <MetaPage>().Delete(metaPage);
                        _unitOfWork.Complete();

                        HttpCookie cookie = new HttpCookie("PopUpMessage");
                        cookie.Value = "Page deleted successfully";
                        Response.Cookies.Add(cookie);

                        return(Redirect("/Publisher/PageViewer.aspx?guid=a63e9f29-a22f-43df-87a0-d0c8dec50548"));
                    }
                }
            }

            return(View(model));
        }