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