public JsonResult DeleteSchema(string id)
        {
            var result = new JsonResult()
            {
                Data = new { success = false, message = "There was an error processing your request." }
            };

            if (String.IsNullOrEmpty(id))
            {
                return(result);
            }

            int moduleId = Int32.Parse(id);
            var module   = Context.Schemas.FirstOrDefault(x => x.SchemaId == moduleId);

            Context.Schemas.Remove(module);
            var success = Context.SaveChanges();

            if (success > 0)
            {
                BookmarkUtil.DeleteBookmarkForUrl("/admin/schemas/editschema/" + id + "/");
                result.Data = new { success = true, message = "The schema has been successfully deleted." };
            }

            return(result);
        }
Exemple #2
0
        public Boolean DeleteContentPage(int id)
        {
            try
            {
                var page       = _context.ContentPages.First(x => x.ContentPageId == id);
                var revisions  = _context.ContentPages.Where(x => x.ParentContentPageId == page.ContentPageId);
                var extenstion = _context.ContentPageExtensions.FirstOrDefault(ext => ext.ContentPageId == id);

                _context.ContentPages.Remove(page);

                if (extenstion != null)
                {
                    _context.ContentPageExtensions.Remove(extenstion);
                }

                if (revisions.Any())
                {
                    _context.ContentPages.RemoveRange(revisions);
                }

                var success = _context.SaveChanges();

                var util = new BookmarkUtil(_context);
                util.DeleteBookmarkForUrl("/admin/pages/editcontent/" + id + "/");

                return(success > 0);
            }
            catch (Exception ex)
            {
                _log.Error(ex);
                return(false);
            }
        }
Exemple #3
0
        public JsonResult DeleteModule(string id)
        {
            var result = new JsonResult()
            {
                Data = new { success = false, message = "There was an error processing your request." }
            };

            if (String.IsNullOrEmpty(id))
            {
                return(result);
            }

            int moduleId = Int32.Parse(id);

            var module    = Context.ContentModules.FirstOrDefault(x => x.ContentModuleId == moduleId);
            var revisions = Context.ContentModules.Where(x => x.ParentContentModuleId == module.ContentModuleId);

            if (revisions.Any())
            {
                Context.ContentModules.RemoveRange(revisions);
            }
            Context.ContentModules.Remove(module);
            var success = Context.SaveChanges();

            if (success > 0)
            {
                BookmarkUtil.DeleteBookmarkForUrl("/admin/modules/" + id + "/");
                result.Data = new { success = true, message = "The module has been successfully deleted." };
            }

            return(result);
        }
        public JsonResult DeleteFolder(String folder)
        {
            var result = new JsonResult();

            string directory = Server.MapPath(ContentGlobals.IMAGEUPLOADDIRECTORY + "/" + folder);

            if (Directory.Exists(directory))
            {
                try
                {
                    Directory.Delete(directory, true);

                    BookmarkUtil.DeleteBookmarkForUrl("/admin/media/managemedia/" + folder + "/");

                    result.Data = new { success = true, directory };
                    return(result);
                }
                catch (SystemException err)
                {
                    result.Data = new { success = false, error = err };
                    return(result);
                }
            }

            result.Data = new { success = false, error = "Folder doesn't exist" };
            return(result);
        }
Exemple #5
0
        public JsonResult DeleteBlog(string id)
        {
            var result = JsonErrorResult;

            if (String.IsNullOrEmpty(id))
            {
                return(result);
            }

            int blogId = Int32.Parse(id);

            var blog = Context.Blogs.FirstOrDefault(x => x.BlogId == blogId);

            Context.Blogs.Remove(blog);
            int success = Context.SaveChanges();

            if (success > 0)
            {
                result.Data = new
                {
                    success = true,
                    message = "Blog removed successfully."
                };

                BookmarkUtil.DeleteBookmarkForUrl("/admin/pages/editblog/" + id + "/");
            }

            return(result);
        }
        public Boolean DeleteContentPage(int id)
        {
            try
            {
                var page = _context.ContentPages.First(x => x.ContentPageId == id);
                var revisions = _context.ContentPages.Where(x => x.ParentContentPageId == page.ContentPageId);
                var extenstion = _context.ContentPageExtensions.FirstOrDefault(ext => ext.ContentPageId == id);

                _context.ContentPages.Remove(page);

                if (extenstion != null)
                {
                    _context.ContentPageExtensions.Remove(extenstion);
                }

                if (revisions.Any())
                {
                    _context.ContentPages.RemoveRange(revisions);
                }

                var success = _context.SaveChanges();

                var util = new BookmarkUtil(_context);
                util.DeleteBookmarkForUrl("/admin/pages/editcontent/" + id + "/");

                return success > 0;
            }
            catch (Exception ex)
            {
                _log.Error(ex);
                return false;
            }
        }
Exemple #7
0
        public JsonResult DeleteModule(int?id)
        {
            if (!id.HasValue)
            {
                return(GenericJsonError);
            }

            var modules = Context.ContentModules.Where(x => x.ContentModuleId == id || x.ParentContentModuleId == id);

            if (!modules.Any())
            {
                return(GenericJsonError);
            }

            try
            {
                Context.ContentModules.RemoveRange(modules);

                Context.SaveChanges();
                BookmarkUtil.DeleteBookmarkForUrl("/admin/modules/" + id + "/");

                return(new JsonResult
                {
                    Data = new { success = true, message = "The module has been successfully deleted." }
                });
            }
            catch (Exception)
            {
                return(GenericJsonError);
            }
        }
Exemple #8
0
        public JsonResult SaveNavigationSet(int navigationId, string name, List <NavigationItem> items)
        {
            var result = new JsonResult()
            {
                Data = new
                {
                    success = false,
                    message = "There was an error processing your request."
                }
            };
            var success = 0;
            // Update the nav name
            var nav = Context.Navigations.FirstOrDefault(x => x.NavigationId == navigationId);

            nav.Name = name;

            // Make sure Nav Items aren't null
            items = items ?? new List <NavigationItem>();

            // Update the navigation children
            foreach (var navItem in items)
            {
                var item = Context.NavigationItems.FirstOrDefault(x => x.NavigationItemId == navItem.NavigationItemId);
                if (item != null)
                {
                    item.Name  = navItem.Name;
                    item.Href  = navItem.Href;
                    item.Order = navItem.Order;
                    item.ParentNavigationId     = navItem.ParentNavigationId;
                    item.ParentNavigationItemId = navItem.ParentNavigationItemId;
                    item.UsesContentPage        = navItem.UsesContentPage;
                    item.ContentPageId          = navItem.ContentPageId;
                    item.TargetBlank            = navItem.TargetBlank;
                    //item.Promo = navItem.Promo;
                }
            }

            success = Context.SaveChanges();

            if (success > 0)
            {
                // Clear the cache of the nav on save
                CachedObjects.GetCacheNavigationList(0, true);

                BookmarkUtil.DeleteBookmarkForUrl("/admin/navigation/editnav/" + navigationId + "/");

                result.Data = new
                {
                    success = true,
                    message = "Saved navigation successfully."
                };
            }

            return(result);
        }