public static ICreateQuestionResult CreateQuestion(CreateQuestionCmd createQuestionCommand) { if (string.IsNullOrWhiteSpace(createQuestionCommand.Title)) { var errors = new List <string>() { "Title is missing" }; return(new QuestionValidationFailed(errors)); } if (createQuestionCommand.Title.Length < 8 && !string.IsNullOrWhiteSpace(createQuestionCommand.Title)) { var errors = new List <string>() { "Title cannot be shorter than 8 characters." }; return(new QuestionValidationFailed(errors)); } if (createQuestionCommand.Title.Length > 180) { var errors = new List <string>() { "Title cannot be longer than 180 characters." }; return(new QuestionValidationFailed(errors)); } if (string.IsNullOrWhiteSpace(createQuestionCommand.Body)) { var errors = new List <string>() { "Body is missing" }; return(new QuestionValidationFailed(errors)); } if (createQuestionCommand.Body.Length < 10 && !string.IsNullOrWhiteSpace(createQuestionCommand.Title)) { var errors = new List <string>() { "Body cannot be shorter than 10 characters." }; return(new QuestionValidationFailed(errors)); } if (createQuestionCommand.Body.Length > 10000) { var errors = new List <string>() { "Body is limited to 10000 characters; you entered 10005." }; return(new QuestionValidationFailed(errors)); } if (createQuestionCommand.Tags.Length < 1) { var errors = new List <string>() { "Please enter at least one tag; see a list of popular tags." }; return(new QuestionValidationFailed(errors)); } if (createQuestionCommand.Tags.Length > 8) { var errors = new List <string>() { "You entered to much tags, you need to delete some of these" }; return(new QuestionValidationFailed(errors)); } if (new Random().Next(10) > 1) { return(new QuestionNotCreated("Question could not be verified")); } var questionId = Guid.NewGuid(); var result = new QuestionCreated(questionId, createQuestionCommand.Title, "*****@*****.**", true); if (result.form) { Console.WriteLine(result.ToString()); } else { QuestionNotCreated feedback = new QuestionNotCreated("Question was closed, can be created !"); } return(result); }
public static ICreateQuestionResult CreateQuestion(CreateQuestionCmd createQuestionCommand) { if (string.IsNullOrWhiteSpace(createQuestionCommand.Title)) { var errors = new List <string>() { "Title is missing" }; return(new QuestionValidationFailed(errors)); } if (createQuestionCommand.Title.Length < 15 && !string.IsNullOrWhiteSpace(createQuestionCommand.Title)) { var errors = new List <string>() { "Title cannot be shorter than 15 characters." }; return(new QuestionValidationFailed(errors)); } if (createQuestionCommand.Title.Length > 150) { var errors = new List <string>() { "Title cannot be longer than 150 characters." }; return(new QuestionValidationFailed(errors)); } if (string.IsNullOrWhiteSpace(createQuestionCommand.Body)) { var errors = new List <string>() { "Body is missing" }; return(new QuestionValidationFailed(errors)); } if (createQuestionCommand.Body.Length < 30 && !string.IsNullOrWhiteSpace(createQuestionCommand.Title)) { var errors = new List <string>() { "Body cannot be shorter than 30 characters." }; return(new QuestionValidationFailed(errors)); } if (createQuestionCommand.Body.Length > 30000) { var errors = new List <string>() { "Body is limited to 30000 characters; you entered 100124." }; return(new QuestionValidationFailed(errors)); } if (createQuestionCommand.Tags.Length < 1) { var errors = new List <string>() { "Please enter at least one tag; see a list of popular tags." }; return(new QuestionValidationFailed(errors)); } if (new Random().Next(10) > 1) { return(new QuestionNotCreated("Question could not be verified")); } var questionId = Guid.NewGuid(); var result = new QuestionCreated(questionId, createQuestionCommand.Title, "*****@*****.**", true); if (result.MLApproved) { result.SetQuestionProfileCount(); Console.WriteLine(result.QuestionProfileNumber); } else { Console.WriteLine(result.QuestionProfileNumber); QuestionNotCreated feedback = new QuestionNotCreated("Question closed. Please edit it or delete it."); } //execute logic return(result); }
private static ICreateQuestionResult ProcessQuestionNotCreated(QuestionNotCreated questionNotCreatedResult) { Console.WriteLine($"Question not created: {questionNotCreatedResult.Feedback}"); return(questionNotCreatedResult); }
private static ICreatedQuestionResult ProcessQuestionNotCreated(QuestionNotCreated questionNotCreatedResult) { Console.WriteLine($"Intrebare necreata: {questionNotCreatedResult.Reason}"); return(questionNotCreatedResult); }
public static ICreateQuestionResult CreateQuestion(CreateQuestionCmd createQuestionCommand) { if (string.IsNullOrWhiteSpace(createQuestionCommand.Title)) { var errors = new List <string>() { "Titlu lipsa" }; return(new QuestionValidationFailed(errors)); } if (createQuestionCommand.Title.Length < 10 && !string.IsNullOrWhiteSpace(createQuestionCommand.Title)) { var errors = new List <string>() { "Titlul nu poate sa contina mai putin de 10 caractere." }; return(new QuestionValidationFailed(errors)); } if (createQuestionCommand.Title.Length > 180) { var errors = new List <string>() { "Titlul nu poate avea mai mult de 200 de caractere." }; return(new QuestionValidationFailed(errors)); } if (string.IsNullOrWhiteSpace(createQuestionCommand.Body)) { var errors = new List <string>() { "Continut lipsa" }; return(new QuestionValidationFailed(errors)); } if (createQuestionCommand.Body.Length < 15 && !string.IsNullOrWhiteSpace(createQuestionCommand.Title)) { var errors = new List <string>() { "Continutul nu poate avea mai putin de 15 caractere." }; return(new QuestionValidationFailed(errors)); } if (createQuestionCommand.Body.Length > 10000) { var errors = new List <string>() { "Continutul nu poate avea mai mult de 1000 caractere. Ati introdus 1001 caractere" }; return(new QuestionValidationFailed(errors)); } if (createQuestionCommand.Tags.Length < 1) { var errors = new List <string>() { "Introduceti cel putin un tag" }; return(new QuestionValidationFailed(errors)); } if (createQuestionCommand.Tags.Length > 10) { var errors = new List <string>() { "Ati introdus prea multe taguri" }; return(new QuestionValidationFailed(errors)); } if (new Random().Next(10) > 1) { return(new QuestionNotCreated("Intrebarea nu s-a putut valida")); } var questionId = Guid.NewGuid(); var result = new QuestionCreated(questionId, createQuestionCommand.Title, "*****@*****.**", true); if (result.form) { Console.WriteLine(result.ToString()); } else { QuestionNotCreated feedback = new QuestionNotCreated("Intrebarea nu s-a creat !"); } return(result); }
private static ICreateQuestionResult ProcessQuestionNotCreated(QuestionNotCreated questionNotCreatedResult) { Console.WriteLine($"Intrebare creata cu succes: {questionNotCreatedResult.Feedback}"); return(questionNotCreatedResult); }
private static ICreateQuestionResult ProcessQuestionNotCreated(QuestionNotCreated questionNotCreated) { Console.WriteLine($"Question not created:{questionNotCreated.Reason}"); return(questionNotCreated); }
private static ICreateQuestionResult OnQuestionNotCreated(QuestionNotCreated questionNotCreatedResult) { Console.WriteLine($"Question not created: { questionNotCreatedResult.messingError}"); return(questionNotCreatedResult); }