コード例 #1
0
        public ActionResult Delete(int cAseId, int postId)
        {
            //refactoring: test PublishCasePost/PublishCasePost in addition if published

            var cAse = _cAseService.Get(cAseId, VersionOptions.Latest);

            if (cAse == null)
            {
                return(HttpNotFound());
            }

            var post = _cAsePostService.Get(postId, VersionOptions.Latest);

            if (post == null)
            {
                return(HttpNotFound());
            }

            if (!Services.Authorizer.Authorize(Permissions.DeleteCasePost, post, T("Couldn't delete cAse post")))
            {
                return(new HttpUnauthorizedResult());
            }

            _cAsePostService.Delete(post);
            Services.Notifier.Information(T("Case post was successfully deleted"));

            return(Redirect(Url.CaseForAdmin(cAse.As <CasePart>())));
        }
コード例 #2
0
        private bool MetaWecAseDeletePost(
            string postId,
            string userName,
            string password,
            IEnumerable <IXmlRpcDriver> drivers)
        {
            IUser user     = ValidateUser(userName, password);
            var   cAsePost = _cAsePostService.Get(Convert.ToInt32(postId), VersionOptions.Latest);

            if (cAsePost == null)
            {
                throw new ArgumentException();
            }

            _authorizationService.CheckAccess(Permissions.DeleteCasePost, user, cAsePost);

            foreach (var driver in drivers)
            {
                driver.Process(cAsePost.Id);
            }

            _cAsePostService.Delete(cAsePost);
            return(true);
        }