private static ICreateQuestionResult ProcessQuestionPublished(QuestionPublished question) { var cmdUser = new CreateUserCommand("CozacRayni", "*****@*****.**"); Console.WriteLine($"Question from {cmdUser.Username} was accepted!"); Console.WriteLine($"Question was published with id: {question.QuestionId}"); Console.WriteLine($"Confirmation email was sent to: {cmdUser.Email}"); return(question); }
public static ICreateQuestionResult CreateQuestion(CreateQuestionCommand createQuestionCommand) { if (string.IsNullOrWhiteSpace(createQuestionCommand.Category) || string.IsNullOrWhiteSpace(createQuestionCommand.Title)) { var errors = new List <string>() { "Invalid category or title!" }; return(new QuestionValidationFailed(errors)); } if (new Random().Next(7) > 1) { return(new QuestionNotPublished("Category or title could not be verified")); } var questionId = Guid.NewGuid(); var result = new QuestionPublished(questionId, createQuestionCommand.Category, createQuestionCommand.Title); return(result); }