private static void VoteQuestion(UnpublishedQuestion question) { var publishedQuestionResult = new PublishQuestService().PublishQuestion(question); publishedQuestionResult.Match( QuestionVote => { new VoteQuestService().SendPermissionToVote(QuestionVote); return(Unit.Default); }, ex => { Console.WriteLine("This question can't be voted! C'ést la vie!"); return(Unit.Default); } ); }
private static void VoteQuestionButton(UnpublishedQuestion question) { var publishedQuestionResult = new PublishQuestionService().PublishQuestion(question); publishedQuestionResult.Match( QuestionVote => { new VoteQuestionService().SendPermisiuneToVote(QuestionVote); return(Unit.Default); }, ex => { Console.WriteLine("Can not vote!"); return(Unit.Default); } ); }
static void Main(string[] args) { var questionResult = UnpublishedQuestion.Create("Can a programmer live without errors?", new List <string>() { "errors", "programming" }); questionResult.Match( Succ: question => { VoteQuestion(question); Console.WriteLine("This question can be voted! *happy dance*"); return(Unit.Default); }, Fail: ex => { Console.WriteLine($"The question couldn't be published because {ex.Message}"); return(Unit.Default); } ); Console.ReadLine(); }
static void Main(string[] args) { var questionResult = UnpublishedQuestion.Create("What is a neural network?", new List <string>() { "python", "neural-network" }); questionResult.Match( Succ: question => { VoteQuestionButton(question); Console.WriteLine("Can vote!"); return(Unit.Default); }, Fail: ex => { Console.WriteLine($"Question could not be published. Reason: {ex.Message}"); return(Unit.Default); } ); Console.ReadLine(); }
public Result <PublishedQuestion> PublishQuestion(UnpublishedQuestion question) { //publica intrebare dupa ce o verificat conditiile return(new PublishedQuestion(question.Question, question.Tag)); }
public Result <PublishedQuestion> PublishQuestion(UnpublishedQuestion question) { return(new PublishedQuestion(question.Question, question.Tag)); }