private QuestionBody CreateQuestionFromCommand(CreateQuestionCmd cmd) { var question = new QuestionBody() { Title = cmd.Title, Body = cmd.Body, Tags = cmd.Tags }; return(question); }
public async Task <HttpResponseMessage> Post(int id, [FromBody] QuestionBody body) { var instance = QuestionService.GetInstance(); var token = GetToken(); if (token == null) { return(Request.CreateResponse(HttpStatusCode.Forbidden, new Forbidden(Request.RequestUri, "token not present in authorization header or not valid"), "application/problem+json")); } var res = await instance.PostQuestionAsync(new CreateQuestion { authorId = token, sessionId = id, message = body.question }); if (res.Success) { return(Request.CreateResponse(HttpStatusCode.OK, new { id = res.Result }, "application/json")); } return(Request.CreateResponse(HttpStatusCode.Conflict, new Conflict(Request.RequestUri, res.Message), "application/problem+json")); }
public void FindKeywords() { KeywordList keywordList = new KeywordList(); // Initialize a bucket to hold the keywords found List <string> thisQuestionsKeywords = new List <string>(); // Start with header - cannot be null string[] headerKeywords = QuestionHeader.Split(' '); // Find useful header keywords and convert to lowercase for (int i = 0; i < headerKeywords.Length; i += 1) { // Create variable to hold lowercase version through each loop string lowercaseVersion = headerKeywords[i].ToLower(); // If not already in list and is useful if (!thisQuestionsKeywords.Contains(lowercaseVersion) && !keywordList.NotUsefulKeywords.Contains(lowercaseVersion)) { thisQuestionsKeywords.Add(lowercaseVersion); } } // Then, collect words from Body string[] bodyKeywords = QuestionBody.Split(' '); for (int b = 0; b < bodyKeywords.Length; b += 1) { string lowercaseVersion = bodyKeywords[b].ToLower(); if (!thisQuestionsKeywords.Contains(lowercaseVersion) && !keywordList.NotUsefulKeywords.Contains(lowercaseVersion)) { thisQuestionsKeywords.Add(lowercaseVersion); } } // Add all the found keywords (hopefully) to the FQ's keyword list keywords.AddRange(thisQuestionsKeywords); }
public QuestionCreated(QuestionBody question) { Question = question; }
public ICreateQuestionResult AddQuestionIfMissing(QuestionWriteContext state, QuestionBody question) { if (state.Questions.Any(p => p.Title.Equals(question.Title))) { return(new QuestionNotCreated()); } if (state.Questions.All(p => p.QuestionId != question.QuestionId)) { state.Questions.Add(question); } return(new QuestionCreated(question)); }