deletegallerypostcommand.cs

来自「community server 源码」· CS 代码 · 共 69 行

CS
69
字号
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using CommunityServer.Components;
using CommunityServer.Galleries.Components;

namespace CommunityServer.ControlPanel.Photos
{
	/// <summary>
	/// Summary description for DeleteGalleryPostCommand.
	/// </summary>
	public class DeleteGalleryPostCommand : GalleryCommand
	{
		public DeleteGalleryPostCommand()
		{
			//
			// TODO: Add constructor logic here
			//
		}

	    public override string Message(GalleryCommandPage page)
	    {
			CSContext context = CSContext.Current;
			int postID = context.GetIntFromQueryString("PostID", 0);
			if(postID > 0)
            {
            	GalleryPost p = GalleryPosts.GetPicture(postID);
                if(p != null)
                {
                    return "Are you sure you want to delete <strong>" + p.Subject + "</strong>? This action can not be undone.";
                }
            }
	        
            throw new Exception("The Gallery Post could not be found");
	    }

	    public override void Action(GalleryCommandPage page)
	    {
			CSContext context = CSContext.Current;
			int postID = context.GetIntFromQueryString("PostID", 0);
			if(postID > 0)
            {
            	GalleryPost p = GalleryPosts.GetPicture(postID);
                if(p != null)
                {
                	GalleryPosts.DeletePicture(p) ;
                    return;
                }
            }

            throw new Exception("The Gallery Post could not be found");
	        
	    }

        public override string Title
        {
            get
            {
                return "Delete Post";
            }
        }

	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?