Exemplo n.º 1
0
        static AskQuestionResult.IAskQuestionResult AskQuestion(AskQuestionCmd cmd)
        {
            if (string.IsNullOrWhiteSpace(cmd.Title))
            {
                string _error = new string ("Invalid title!");
                return(new AskQuestionResult.QuestionNotAdded(_error));
            }

            if (string.IsNullOrWhiteSpace(cmd.Text))
            {
                string _error = new string ("Invalid text!");
                return(new AskQuestionResult.QuestionNotAdded(_error));
            }

            if (new Random().Next(10) == 1)
            {
                var _error = new List <string> {
                    "ML validation failed!"
                };
                return(new AskQuestionResult.QuestionValidationFailed(_error));
            }

            var Id     = Guid.NewGuid();
            var result = new AskQuestionResult.QuestionAdded(Id, cmd.Title, cmd.Text, cmd.Tags);

            return(result);
        }
Exemplo n.º 2
0
        static AskQuestionResult.IAskQuestionResult AskQuestion(AskQuestionCmd cmd)
        {
            if (string.IsNullOrWhiteSpace(cmd.Title))
            {
                string error = new string ("Title must not be empty!");
                return(new AskQuestionResult.QuestionNotAdded(error));
            }

            if (string.IsNullOrWhiteSpace(cmd.Text))
            {
                string error = new string ("Body must not be empty!");
                return(new AskQuestionResult.QuestionNotAdded(error));
            }

            if (new Random().Next(10) > 7) //simulare analiza text
            {
                var error = new List <string> {
                    "ML validation failed!"
                };
                return(new AskQuestionResult.QuestionValidationFailed(error));
            }

            var Id     = Guid.NewGuid();
            var result = new AskQuestionResult.QuestionAdded(Id, cmd.Title, cmd.Text, cmd.Tags);

            return(result);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            List <string> _taglist = new List <string> {
                "DDD", "Beginner"
            };
            var cmd    = new AskQuestionCmd("What is DDD?", "Hello, I would like to know more details about Domain Driver Design. Thanks!", _taglist);
            var result = AskQuestion(cmd);

            result.Match(
                ProcessQuestionAdded,
                ProcessQuestionNotAdded,
                ProcessQuestionValidationFailed
                );
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            List <string> taglist = new List <string> {
                "C#", "WFA"
            };
            var cmd    = new AskQuestionCmd("How to change button size dynamically", "Hi, how can i change a button's size programatically, while the app is running, when something is pressed for example", taglist);
            var result = AskQuestion(cmd);

            result.Match(
                ProcessQuestionAdded,
                ProcessQuestionNotAdded,
                ProcessQuestionValidationFailed
                );
        }