Exemplo n.º 1
0
        public ActionResult Close(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.CloseThread, threadPart, T("Not allowed to close thread")))
            {
                return(new HttpUnauthorizedResult());
            }

            var viewModel = new ThreadCloseAdminViewModel {
                ThreadId = threadPart.Id,
            };

            return(View(viewModel));
        }
Exemplo n.º 2
0
        public ActionResult Close(int threadId, string returnUrl, ThreadCloseAdminViewModel viewModel)
        {
            var threadPart = _threadService.Get(threadId, VersionOptions.Latest);

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

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

            threadPart.ClosedBy          = _orchardServices.WorkContext.CurrentUser;
            threadPart.ClosedOnUtc       = _clock.UtcNow;
            threadPart.ClosedDescription = viewModel.Description;

            _orchardServices.ContentManager.Publish(threadPart.ContentItem);

            _orchardServices.Notifier.Information(T("{0} has been closed.", threadPart.TypeDefinition.DisplayName));

            return(this.RedirectLocal(returnUrl, "~/"));
        }