public IActionResult PublishPage(string ID, string ReturnUrl)
        {
            var result = Service.Publish(Service.Get(ID));

            if (result.HasViolation)
            {
                ModelState.AddUnknownError(result.ErrorMessage);
                return(Edit(ID));
            }
            return(Redirect(ReturnUrl));
        }
 public override IActionResult Edit(PageEntity entity)
 {
     ViewBag.OldVersions = Service.Get(m => m.ReferencePageID == entity.ID && m.IsPublishedPage == true).OrderBy(m => m.PublishDate);
     ViewBag.Page        = entity;
     if (!ModelState.IsValid)
     {
         return(View(entity));
     }
     try
     {
         ViewBag.Page = entity;
         Service.Update(entity);
     }
     catch (PageExistException ex)
     {
         ModelState.AddModelError("PageUrl", ex.Message);
         return(View(entity));
     }
     if (entity.ActionType == ActionType.Design)
     {
         return(RedirectToAction("Design", new { entity.ID }));
     }
     else if (entity.ActionType == ActionType.Delete)
     {
         Service.Remove(entity);
         return(RedirectToAction("Index"));
     }
     else if (entity.ActionType == ActionType.Publish)
     {
         var result = Service.Publish(entity);
         if (result.HasViolation)
         {
             ModelState.AddUnknownError(result.ErrorMessage);
             return(View(entity));
         }
         return(RedirectView(entity.ID, false));
     }
     return(RedirectToAction("Index", new { PageID = entity.ID }));
 }