コード例 #1
0
        private void CreateNew(string updatingUserName, Article2 article)
        {
            if (!updatingUserName.IsInRole("Author") &&
                !updatingUserName.IsInRole("Editor") &&
                !updatingUserName.IsInRole("Administrator"))
            {
                throw new ApplicationException("You do not have permission to create an article.");
            }
            article.AuthorUserName        = updatingUserName;
            article.DateCreated           = DateTime.Now;
            article.DateLastUpdated       = DateTime.Now;
            article.LastUpdatedByUserName = updatingUserName;
            article.Status = ArticleState.Draft;

            _articleRepository.Save(article);
        }
コード例 #2
0
        public void Save(string updatingUserName, Article2 article)
        {
            if (article.Id == 0)
            {
                CreateNew(updatingUserName, article);
                return;
            }
            if (updatingUserName.IsInRole("Administrator") ||
                updatingUserName.IsInRole("Editor") ||
                (updatingUserName.IsInRole("Author") && updatingUserName == article.AuthorUserName))
            {
                article.DateLastUpdated       = DateTime.Now;
                article.LastUpdatedByUserName = updatingUserName;

                _articleRepository.Save(article);
            }
        }
コード例 #3
0
 public override void Publish(string updatingUserName, Article2 article)
 {
     throw new ApplicationException("Can only publish articles that have been approved.");
 }
コード例 #4
0
 public override void Approve(string updatingUserName, Article2 article)
 {
     throw new ApplicationException("Can only approve articles from the Needs Editing state.");
 }
コード例 #5
0
 public override void SubmitForEditing(string updatingUserName, Article2 article)
 {
     throw new NotImplementedException();
 }
コード例 #6
0
 public abstract void Publish(string updatingUserName, Article2 article);
コード例 #7
0
 public abstract void Approve(string updatingUserName, Article2 article);
コード例 #8
0
 public abstract void SubmitForEditing(string updatingUserName, Article2 article);
コード例 #9
0
 public void Save(Article2 article)
 {
     // save to database
 }