Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var cmd    = new CreateNewQuestionCmd("Tool for lossless image compression", "Is there any tool or web service that I can use so that I give it a directory of uncompressed images(say .gif) and it returns me a directory of images with all of them compressed?", "image-compression");
            var result = CreateNewQuestion(cmd);

            var createQuestionEvent = result.Match(ProcessQuetionPosted, ProcessQuestionNotPosted, ProcessInvalidQuestion);

            Console.ReadLine();
        }
Exemplo n.º 2
0
        public static ICreateNewQuestionResult CreateNewQuestion(CreateNewQuestionCmd createQuestion)
        {
            if (string.IsNullOrWhiteSpace(createQuestion.DescriptionOfQuestion))
            {
                var errors = new List <string>()
                {
                    "Invalid Description"
                };
                return(new QuestionValidationFailed(errors));
            }

            if (string.IsNullOrEmpty(createQuestion.Title))
            {
                return(new QuestionNotPosted("Missing title!Please give me a title!"));
            }

            var questionId = Guid.NewGuid();
            var result     = new QuestionPosted(questionId, createQuestion.DescriptionOfQuestion);

            return(result);
        }