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