コード例 #1
0
ファイル: Program.cs プロジェクト: cozacraynhardt/PSSC-2020
        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);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: cozacraynhardt/PSSC-2020
        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);
        }