Пример #1
0
        public ActionResult Move(int threadId, string returnUrl, ThreadMoveAdminViewModel viewModel)
        {
            var threadPart = _threadService.Get(threadId, VersionOptions.Latest);

            if (threadPart == null)
            {
                return(HttpNotFound(T("Could not find thread").Text));
            }

            if (!_orchardServices.Authorizer.Authorize(Permissions.MoveThread, threadPart, T("Not allowed to move thread")))
            {
                return(new HttpUnauthorizedResult());
            }

            var forumPart = _forumService.Get(viewModel.ForumId, VersionOptions.Latest);

            if (forumPart == null)
            {
                return(HttpNotFound(T("Could not find forum").Text));
            }

            var currentForumName = threadPart.ForumPart.As <ITitleAspect>().Title;
            var newForumName     = forumPart.As <ITitleAspect>().Title;

            threadPart.ForumPart = forumPart;

            _orchardServices.ContentManager.Publish(threadPart.ContentItem);

            _orchardServices.Notifier.Information(T("{0} has been moved from {1} to {2}.", threadPart.TypeDefinition.DisplayName, currentForumName, newForumName));

            return(this.RedirectLocal(returnUrl, "~/"));
        }
Пример #2
0
        public ActionResult Move(int threadId)
        {
            var threadPart = _threadService.Get(threadId, VersionOptions.Latest);

            if (threadPart == null)
            {
                return(HttpNotFound(T("could not find thread").Text));
            }

            if (!_orchardServices.Authorizer.Authorize(Permissions.MoveThread, threadPart, T("Not allowed to move thread")))
            {
                return(new HttpUnauthorizedResult());
            }

            var forums = _forumService.Get();
            //What if I have 1 forum?

            var viewModel = new ThreadMoveAdminViewModel {
                ThreadId        = threadPart.Id,
                AvailableForums = forums
            };

            return(View(viewModel));
        }