Esempio n. 1
0
        /// <summary>
        /// Delete the specified request.
        /// </summary>
        /// <param name="request">Request.</param>
        public object Delete(CommunityDeleteRequest request)
        {
            var context = TepWebContext.GetWebContext(PagePrivileges.UserView);

            try {
                context.Open();
                context.LogInfo(this, string.Format("/community/{{Identifier}} DELETE Identifier='{0}'", request.Identifier));
                ThematicCommunity domain = ThematicCommunity.FromIdentifier(context, request.Identifier);
                if (domain.CanUserManage(context.UserId))
                {
                    domain.Delete();
                }
                else
                {
                    throw new UnauthorizedAccessException(CustomErrorMessages.ADMINISTRATOR_ONLY_ACTION);
                }
                context.LogDebug(this, string.Format("Community {0} deleted by user {1}", domain.Identifier, User.FromId(context, context.UserId).Username));
                context.Close();
            } catch (Exception e) {
                context.LogError(this, e.Message, e);
                context.Close();
                throw e;
            }
            return(new WebResponseBool(true));
        }