public override void Execute() { string title = this.Data[1]; string body = this.Data[2]; if (!this.Forum.IsLogged) { throw new CommandException(Messages.NotLogged); } var question = new Question(this.Forum.Questions.Count + 1, this.Forum.CurrentUser, title, body); this.Forum.Questions.Add(question); this.Forum.Output.AppendFormat(Messages.PostQuestionSuccess, question.Id).AppendLine(); }
public override void Execute() { if (!this.Forum.IsLogged) { throw new CommandException(Messages.NotLogged); } string title = this.Data[1]; string body = this.Data[2]; IQuestion newQuestion = new Question(title, this.Forum.Questions.Count + 1, body, this.Forum.CurrentUser); this.Forum.Questions.Add(newQuestion); this.Forum.Output.AppendLine(string.Format(Messages.PostQuestionSuccess, newQuestion.Id)); }
public override void Execute() { if (!this.Forum.IsLogged) throw new CommandException(Messages.NotLogged); int id = this.Forum.Questions.Count + 1; var title = this.Data[1]; var body = this.Data[2]; IQuestion question = new Question(id, title, body, this.Forum.CurrentUser); this.Forum.Questions.Add(question); this.Forum.Output.AppendLine(string.Format(Messages.PostQuestionSuccess, id)); }
public override void Execute() { var questions = this.Forum.Questions; string title = Data[1]; string body = Data[2]; IUser author = this.Forum.CurrentUser; if (author == null) { throw new CommandException(Messages.NotLogged); } IQuestion question = new Question(questions.Count + 1, body, author, title, new List<IAnswer>()); questions.Add(question); author.Questions.Add(question); this.Forum.Output.AppendLine(string.Format(Messages.PostQuestionSuccess, question.Id)); }
public override void Execute() { var questions = this.Forum.Questions; var title = this.Data[1]; var body = this.Data[2]; if (!Forum.IsLogged) { throw new CommandException(Messages.NotLogged); } var question = new Question((questions.Count + 1), body, Forum.CurrentUser, title); questions.Add(question); this.Forum.Output.AppendLine(string.Format(Messages.PostQuestionSuccess, question.Id)); }
public override void Execute() { var questions = this.Forum.Questions; var questionTitle = this.Data[1]; var questionBody = this.Data[2]; IUser currentUser = this.Forum.CurrentUser; if (currentUser == null) { throw new CommandException(Messages.NotLogged); } var question = new Question(questions.Count + 1, questionTitle, questionBody, currentUser); this.Forum.Questions.Add(question); this.Forum.Output.AppendLine( string.Format(Messages.PostQuestionSuccess, question.Id)); }
public override void Execute() { this.Forum.CurrentQuestion = null; if (!this.Forum.IsLogged) { this.Forum.Output.AppendLine(string.Format(Messages.NotLogged)); return; } string title = this.Data[1]; string body = this.Data[2]; var questions = this.Forum.Questions; Question currentQuestion = new Question(questions.Count + 1, title, body, this.Forum.CurrentUser); this.Forum.CurrentUser.Questions.Add(currentQuestion); questions.Add(currentQuestion); this.Forum.Output.AppendLine(string.Format(Messages.PostQuestionSuccess, currentQuestion.Id)); }