Beispiel #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);
        }
Beispiel #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);
            }
        }
Beispiel #3
0
 public override void Publish(string updatingUserName, Article2 article)
 {
     throw new ApplicationException("Can only publish articles that have been approved.");
 }
Beispiel #4
0
 public override void Approve(string updatingUserName, Article2 article)
 {
     throw new ApplicationException("Can only approve articles from the Needs Editing state.");
 }
Beispiel #5
0
 public override void SubmitForEditing(string updatingUserName, Article2 article)
 {
     throw new NotImplementedException();
 }
Beispiel #6
0
 public abstract void Publish(string updatingUserName, Article2 article);
Beispiel #7
0
 public abstract void Approve(string updatingUserName, Article2 article);
Beispiel #8
0
 public abstract void SubmitForEditing(string updatingUserName, Article2 article);
Beispiel #9
0
 public void Save(Article2 article)
 {
     // save to database
 }