public async Task <ActionResult> Add(AnswerCreateRequest request, CancellationToken cancel) { var command = new AnswerCreateCommand(request.QuestionId, DateTime.Now, request.Content, _markdown.TransformIntoHTML(request.Content)); var result = await _mediator.ExecuteAsync <AnswerCreateCommand, AnswerCreateCommandResult>(command, User.GetAppIdentity(), cancel); return(Redirect(Url.RouteUrl("QuestionRead", new { id = result.QuestionId, slug = result.Slug, action = "get" }) + "#ans_" + result.AnswerId)); }
private void AppendAnswer(String questionId, XElement answer, ConcurrentDictionary <String, String> idmap, IDictionary <String, String> usermap) { if (answer.Attribute("OwnerUserId") == null || answer.Attribute("Id") == null) { return; } var userId = answer.Attribute("OwnerUserId").Value; var creationDate = DateTime.Parse(answer.Attribute("CreationDate").Value); var command = new AnswerCreateCommand(questionId, creationDate, answer.Attribute("Body").Value, answer.Attribute("Body").Value); var user = new SimpleQAPrincipal(usermap[userId], "whatever", "", 0); var result = _mediator.ExecuteAsync <AnswerCreateCommand, AnswerCreateCommandResult>(command, user.GetAppIdentity(), CancellationToken.None).Result; idmap.TryAdd(answer.Attribute("Id").Value, result.QuestionId + "@" + result.AnswerId); Console.WriteLine("Added answer for: " + questionId); }