public void AcceptArticle(string articleTitle, string articleContent, string articleComment, DateTime articlePublishDate, int userId, int mediaManagerId, int articleStatusId, int articleStateId, int articleId) { string currentStateName = db.tbl_Articles.SingleOrDefault(x => x.ArticleId == articleId).tbl_ArticleStates.StateName; if (currentStateName == null) throw new ArgumentNullException("currentStateName"); string fullstringtype = "SteveDelezioSEAssignment2Sit1.Models.Patterns.StatePattern." + currentStateName; Type s = Type.GetType(fullstringtype); // Type s = Type.GetType("SteveDelezioSEAssignment2Sit1.Models.Patterns.StatePattern.ReviewByWriterArticleState"); //ConstructorInfo ctor = s.GetConstructor(new[] { typeof(IArticleState) }); // (IArticleState)s.GetConstructor() ArticleFactory afe = new TextArticleFactory(); Articles af = afe.CreateTextArticlewitId((IArticleState)Activator.CreateInstance(s), articleTitle, articleContent, articleComment, articlePublishDate, userId, mediaManagerId, articleStatusId, articleStateId, articleId); //ArticleFactory af = new TextArticle((IArticleState)Activator.CreateInstance(s), articleTitle, articleContent, articleComment, // articlePublishDate, userId, mediaManagerId, articleStatusId, articleStateId, articleId); af.AcceptArticle(); }
public void CreateArticle(string articleTitle, string articleContent, string articleComment, DateTime articlePublishDate, int userId, int mediaManagerId, int articleStatusId, int articleStateId) { // Type s = Type.GetType("SteveDelezioSEAssignment2Sit1.Models.Patterns.StatePattern.NewArticleState.cs"); //string state =db.tbl_Articles.SingleOrDefault(x => x.ArticleId == 1).tbl_ArticleStates.StateName; // string fullname = "SteveDelezioSEAssignment2Sit1.Models.Patterns.StatePattern." + state; if (articleTitle.Length != 0 && articleContent.Length != 0) { Type s = Type.GetType("SteveDelezioSEAssignment2Sit1.Models.Patterns.StatePattern.NewArticleState"); //ConstructorInfo ctor = s.GetConstructor(new[] { typeof(IArticleState) }); // (IArticleState)s.GetConstructor() ArticleFactory afe = new TextArticleFactory(); Articles af = afe.CreateTextArticle((IArticleState) Activator.CreateInstance(s), articleTitle, articleContent, articleComment, articlePublishDate, userId, mediaManagerId, articleStatusId, articleStateId); // ArticleFactory af = new TextArticle((IArticleState)Activator.CreateInstance(s), articleTitle, articleContent, articleComment, // articlePublishDate, userId, mediaManagerId, articleStatusId, articleStateId); af.CreateArticle(); } }
public void DeleteArticle(int articleId) { string currentStateName = db.tbl_Articles.SingleOrDefault(x => x.ArticleId == articleId).tbl_ArticleStates.StateName; if (currentStateName == null) throw new ArgumentNullException("currentStateName"); string fullstringtype = "SteveDelezioSEAssignment2Sit1.Models.Patterns.StatePattern." + currentStateName; Type s = Type.GetType(fullstringtype); // Type s = Type.GetType("SteveDelezioSEAssignment2Sit1.Models.Patterns.StatePattern.NewArticleState"); //ConstructorInfo ctor = s.GetConstructor(new[] { typeof(IArticleState) }); // (IArticleState)s.GetConstructor() ArticleFactory afe = new TextArticleFactory(); Articles af = afe.CreateTextArticlewitIdandState((IArticleState) Activator.CreateInstance(s), articleId); // ArticleFactory af = new TextArticle((IArticleState)Activator.CreateInstance(s), articleId); af.DeleteArticle(); }