public static ICreateQuestionResult CreateQuestion(CreateQuestionCmd createQuestionCommand) { if (string.IsNullOrEmpty(createQuestionCommand.Title)) { var errors = new List <string>() { "Invalid question title" }; return(new QuestionValidationFailed(errors)); } if (string.IsNullOrEmpty(createQuestionCommand.Body)) { var errors = new List <string>() { "Invalid question body" }; return(new QuestionValidationFailed(errors)); } if (createQuestionCommand.Tags.Count == 0) { var errors = new List <string>() { "Invalid question tags" }; return(new QuestionValidationFailed(errors)); } var result = new QuestionPosted(createQuestionCommand.Title); return(result); }
static CreateQuestionResult.IAskQuestionResult CreateQuestion(CreateQuestionCmd createQuestionCommand) { if (string.IsNullOrWhiteSpace(createQuestionCommand.Title)) { string error = new string ("Title is empty!But it hasn't had to be"); return(new CreateQuestionResult.QuestionNotAdded(error)); } if (string.IsNullOrWhiteSpace(createQuestionCommand.Text)) { string error = new string ("Body is empty!But it hasn't had to be"); return(new CreateQuestionResult.QuestionNotAdded(error)); } if (new Random().Next(10) > 7) { var error = new List <string> { "Validation Failed" }; return(new CreateQuestionResult.QuestionValidationFailed(error)); } var Id = Guid.NewGuid(); var result = new CreateQuestionResult.QuestionAdded(Id, createQuestionCommand.Title, createQuestionCommand.Text, createQuestionCommand.Tags); return(result); }
static void Main(string[] args) { var cmd = new CreateQuestionCmd("How to change the placeholder for the input", "How can i change the css properties for the placeholder in input field", new string[] { "Java", "AngularJS" }, ""); var result = CreateQuestion(cmd); result.Match( ProcessQuestionCreated, ProcessQuestionNotCreated, ProcessInvalidQuestion ); Console.ReadLine(); if (result.form == true) { Console.WriteLine("Would you like to give a vote?"); Console.WriteLine("YES or NO?"); string decision = Console.ReadLine(); if (decision.Equals("Y")) { Console.WriteLine("Would you like to give a positive or negative vote ? "); string vote = Console.ReadLine(); if (vote.Equals("P")) { result.getVotes(1); } else if (vote.Equals("N")) { ; } result.getVotes(-1); } } }
public static ICreateQuestionResult CreateQuestion(CreateQuestionCmd createQuestionCommand) { bool isMLApproved = true; if (string.IsNullOrWhiteSpace(createQuestionCommand.Title)) { var errors = new List <string>() { "Invalid title" }; return(new QuestionValidationFailed(errors)); } else if (string.IsNullOrWhiteSpace(createQuestionCommand.Body)) { var errors = new List <string>() { "Invalid body" }; return(new QuestionValidationFailed(errors)); } if (new Random().Next(5) > 1) { isMLApproved = false; return(new QuestionNotCreated("Question is not approved")); } var questionId = Guid.NewGuid(); var results = new QuestionCreated(questionId, createQuestionCommand.Title, "*****@*****.**", isMLApproved); return(results); }
static CreateQuestionResult.IAskQuestionResult AskQuestion(CreateQuestionCmd cmd) { if (string.IsNullOrWhiteSpace(cmd.Title)) { string error = new string ("Title is empty! But it hasn't had to be..."); return(new CreateQuestionResult.QuestionNotAdded(error)); } if (string.IsNullOrWhiteSpace(cmd.Text)) { string error = new string ("Body is empty but it hasn't had to be...!"); return(new CreateQuestionResult.QuestionNotAdded(error)); } if (new Random().Next(10) > 7) //simulare analiza text { var error = new List <string> { " validation failed!" }; return(new CreateQuestionResult.QuestionValidationFailed(error)); } var Id = Guid.NewGuid(); var result = new CreateQuestionResult.QuestionAdded(Id, cmd.Title, cmd.Text, cmd.Tags); return(result); }
public static ICreateQuestionResult CreateQuestion(CreateQuestionCmd createQuestionCommand) { if (string.IsNullOrWhiteSpace(createQuestionCommand.Title)) { var errors = new List <string>() { "Invlaid title" }; return(new QuestionValidationFailed(errors)); } if (string.IsNullOrWhiteSpace(createQuestionCommand.Body)) { var errors = new List <string>() { "Invlaid text" }; return(new QuestionValidationFailed(errors)); } if (new Random().Next(10) > 1) { return(new QuestionNotCreated("Text could not be verified")); } var questionId = Guid.NewGuid(); var result2 = new QuestionCreated(questionId, createQuestionCommand.Title); //execute logic return(result2); }
static void Main(string[] args) { var cmd = new CreateQuestionCmd("Title", "Body", "C#"); var result = CreateNewQuestion(cmd); var createQuestionEvent = result.Match(ProcessQuetionPosted, ProcessQuestionNotPosted, ProcessInvalidQuestion); Console.ReadLine(); }
static void Main(string[] args) { var replyResult = UnvalidatedReply.Create("Respond to How to use sockets in C#" , "I have tried for a lot of times to use sockets in C# and I followed several tutorials"); var cmd = new CreateQuestionCmd("How to use sockets in C#" , "I have tried for a lot of times to use sockets in C# and I followed several tutorials " + "\nCan anyone to help me ? " , new string[] { "C#", "Sockets" }, "https://www.infoworld.com/article/3016922/how-to-work-with-sockets-in-c.html "); var result = CreateQuestion(cmd); result.Match( ProcessQuestionCreated, ProcessQuestionNotCreated, ProcessInvalidQuestion ); replyResult.Match( Succ: reply => { SendValidityConfirmation(reply); Console.WriteLine("Reply is valid. Reply posted"); return(Unit.Default); }, Fail: ex => { Console.WriteLine($"Invalid reply. Reason: {ex.Message}"); return(Unit.Default); } ); Console.ReadLine(); if (result.form == true) { Console.WriteLine("Do you want to vote this ?"); Console.WriteLine("Yes or No ? Y or N"); string decision = Console.ReadLine(); if (decision.Equals("Y")) { Console.WriteLine("You can give a positive or negative vote: P or N ?"); string vote = Console.ReadLine(); if (vote.Equals("P")) { result.getVotes(1); } else if (vote.Equals("N")) { result.getVotes(-1); } } } }
static void Main(string[] args) { int[] vote = new int[5] { -1, 1, -1, 1, 1 }; var cmd = new CreateQuestionCmd("Question", "Description", "C#", vote); var result = CreateNewQuestion(cmd); var createQuestionEvent = result.Match(ProcessQuetionPosted, ProcessQuestionNotPosted, ProcessInvalidQuestion); Console.ReadLine(); }
public static void QuestionMain() { var cmd = new CreateQuestionCmd("Test Title", "Test Body", new string[] { "c#", "python", "c++", "java" }); var result = CreateQuestion(cmd); result.Match( ProcessQuestionCreated, ProcessQuestionNotCreated, ProcessInvalidQuestion ); Console.ReadLine(); }
static void Main(string[] args) { var cmd = new CreateQuestionCmd("Titlu", "Continut", "Taguri"); var result = CreateQuestion(cmd); result.Match( ProcessQuestionCreated, ProcessQuestionNotCreated, ProcessInvalidQuestion ); Console.ReadLine(); }
static void Main(string[] args) { var cmd = new CreateQuestionCmd("Titlu1", "Descriere1", "c#"); var result = CreateQuestion(cmd); result.Match( ProcessQuestionCraeted, ProcessQuestionNotCreated, ProcessInvalidQuestion ); Console.ReadLine(); }
static void Main(string[] args) { var cmd1 = new CreateQuestionCmd("How to add a class in c++?", "c++"); var result = CreateQuestion(cmd1); result.Match( ProcessQuestionCreated, ProcessQuestionNotCreated, ProcessInvalidQuestion ); Console.ReadLine(); }
static void Main(string[] args) { var cmd = new CreateQuestionCmd("Question", "This is a question", "c++"); var result = CreateQuestion(cmd); result.Match( ProcessQuestionCreated, ProcessQuestioFailed, ProcessInvalidQuestion ); Console.ReadLine(); }
static void Main(string[] args) { var cmd = new CreateQuestionCmd("Ion", string.Empty, "Ionescu", "*****@*****.**"); var result = CreateQuestion(cmd); result.Match( ProcessQuestionCreated, ProcessQuestionNotCreated, ProcessInvalidQuestion ); Console.ReadLine(); }
static void Main(string[] args) { var cmd = new CreateQuestionCmd("titlu intrebare", string.Empty, "continut"); var result = CreateQuestion(cmd); result.Match( ProcessQuestionPosted, ProcessQuestionNotCreated, ProcessInvalidQuestion ); Console.ReadLine(); }
static void Main(string[] args) { var cmd1 = new CreateQuestionCmd("How can I get the internal error message to log?", "c++"); var result = CreateQuestion(cmd1); result.Match( ProcessQuestionCreated, ProcessQuestionNotCreated, ProcessInvalidQuestion ); Console.ReadLine(); }
static void Main(string[] args) { var cmd = new CreateQuestionCmd("Titul", string.Empty, "Intrebare?", "c#"); var result = CreateQuestion(cmd); result.Match( ProcessQuestionCreated, ProcessQuestionNotCreated, ProcessInvalidQuestion ); Console.ReadLine(); }
static void Main(string[] args) { var tag = "c#".Split(',').ToList(); var cmd = new CreateQuestionCmd("Does dontDestroyOnLoad only work a single time ? ", "Can someone give me concrete details ? ", tag); var result = CreateQuestion(cmd); result.Match( ProcessQuestionPosted, ProcessQuestionNotPosted, ProcessInvalidQuestion ); Console.ReadLine(); }
static void Main(string[] args) { var tag = "c#,java".Split(',').ToList(); var cmd = new CreateQuestionCmd("Can I have blocking remote call in Flux.generate state generator", "I am generating a Flux from a series of blocking REST API calls, each call depends on the result of previous call.", tag); var result = CreateQuestion(cmd); result.Match( ProcessQuestionPosted, ProcessQuestionNotPosted, ProcessInvalidQuestion ); Console.ReadLine(); }
static void Main(string[] args) { List <string> taglist = new List <string> { "HTML", "PHP" }; var cmd = new CreateQuestionCmd("How to create a submeniu", "How can i stylized a drop-down menu with css ", taglist); var result = CreateQuestionCmd(cmd); result.Match( ProcessQuestionAdded, ProcessQuestionNotAdded, ProcessQuestionValidationFailed ); }
static void Main(string[] args) { var tag = "c#,java".Split(',').ToList(); var cmd = new CreateQuestionCmd("How to use Tuplets?", "I have more lists and need one tuplet", tag); var result = CreateQuestion(cmd); result.Match( ProcessQuestionPosted, ProcessQuestionNotPosted, ProcessInvalidQuestion ); Console.ReadLine(); }
static void Main(string[] args) { var tag = "visual studio, debugging".Split(',').ToList(); var cmd = new CreateQuestionCmd("How do I remedy “The breakpoint will not currently be hit. No symbols have been loaded for this document.” warning?", "Can someone give me concrete details?", tag); var result = CreateQuestion(cmd); result.Match( ProcessQuestionPosted, ProcessQuestionNotPosted, ProcessInvalidQuestion ); Console.ReadLine(); }
static void Main(string[] args) { String[] tags = new string[3] { "C#", "PHP", "Python" }; int[] vote = new int[5] { -1, 1, -1, 1, 1 }; var cmd = new CreateQuestionCmd("Title", "Body", tags, vote); var result = CreateQuestion(cmd); var createQuestionEvent = result.Match(ProcessQuetionPosted, ProcessQuestionNotPosted, ProcessInvalidQuestion); Console.ReadLine(); }
public static ICreateQuestionResult QuestionCreated(CreateQuestionCmd createQuestionCommand) { if (string.IsNullOrWhiteSpace(createQuestionCommand.Title)) { var errors = new List <string>() { "Invlaid Title" }; return(new QuestionValidationFailed(errors)); } var result = new QuestionCreated(quefileTi, createQuestionCommand.Title); //execute logic return(result); }
static void Main(string[] args) { List <string> taglist = new List <string> { "HTML", "PHP" }; var cmd = new CreateQuestionCmd("How to create a website", "How can i create a menu bar with php", taglist); var result = CreateQuestion(cmd); result.Match( ProcessQuestionCreated, ProcessQuestionNotCreated, ProcessInvalidQuestion ); Console.ReadLine(); }
static void Main(string[] args) { var cmd = new CreateQuestionCmd("How to create a custom attribute in C#" , "I have tried lots of times but still I am not able to understand the usage of custom attributes (I have already gone through lots of links)." + "\nCan anyone please explain to me a very basic example of a custom attribute with code ? " , new string[] { "C#", "ComponentModel", "Annotations" }); var result = CreateQuestion(cmd); result.Match( ProcessQuestionCreated, ProcessQuestionNotCreated, ProcessInvalidQuestion ); Console.ReadLine(); }
static void Main(string[] args) { var cmd = new CreateQuestionCmd("Difference between automation testing tool and automation framework" , "I am trying to understand the difference between automation frameworks and automation testing tools. " + "\nAccording to Test Automation in wikipedia a tool is dependent on the environment whereas a framework provides the structure for running the tool." , new string[] { "testing", "frameworks", "automation" }); var result = CreateQuestion(cmd); result.Match( ProcessQuestionCreated, ProcessQuestionNotCreated, ProcessInvalidQuestion ); Console.ReadLine(); }
static void Main(string[] args) { var cmd = new CreateQuestionCmd("Some issue with System.out.println in JAVA" , "I have tried lots of JDK's and JRE's from Oracle website" + "\nCan anyone to help me ? " , new string[] { "JAVA" }, "I finally did, I install JDK 8 and JRE 8 and I restart the compiler :)"); var result = CreateQuestion(cmd); result.Match( ProcessQuestionCreated, ProcessQuestionNotCreated, ProcessInvalidQuestion ); Console.ReadLine(); }
static void Main(string[] args) { var cmd = new CreateQuestionCmd("How to use sockets in C#" , "I have tried for a lot of times to use sockets in C# and I followed several tutorials " + "\nCan anyone to help me ? " , new string[] { "C#", "Sockets" }, "https://www.infoworld.com/article/3016922/how-to-work-with-sockets-in-c.html "); var result = CreateQuestion(cmd); result.Match( ProcessQuestionCreated, ProcessQuestionNotCreated, ProcessInvalidQuestion ); Console.ReadLine(); }