public async Task <IActionResult> CreateReply(int questionId, [FromBody] GetQuestionReplyCmd getQuestionReplyCmd) { QuestionWriteContext ctx = new QuestionWriteContext( new EFList <Post>(_dbContext.Post), new EFList <User>(_dbContext.User)); var dependencies = new QuestionDependencies(); var expr = from createQuestionResult in QuestionDomain.GetQuestionReply(getQuestionReplyCmd) select createQuestionResult; var r = await _interpreter.Interpret(expr, ctx, dependencies); _dbContext.SaveChanges(); return(r.Match( created => Ok(created.Replies.PostId), notCreated => StatusCode(StatusCodes.Status500InternalServerError, "Question could not be created."),//todo return 500 (), invalidRequest => BadRequest("Invalid request."))); }
public async Task <IActionResult> CreateReply(int questionId, [FromBody] GetQuestionReplyCmd getQuestionReplyCmd) { // o noua comanda, o operatiune de comanda si din ea sa trimitem un mesaj prin streamul de eventuri ca sa ne dam seama ca s-a create un nou reply // trimitem un mesaj printr-un stream catre un grain // id-ul grainului este id-ul intrebarii QuestionWriteContext ctx = new QuestionWriteContext( new EFList <Post>(_dbContext.Post), new EFList <User>(_dbContext.User), new EFList <Post>(_dbContext.Post)); var dependencies = new QuestionDependencies(); var expr = from createQuestionResult in QuestionDomain.GetQuestionReply(getQuestionReplyCmd) select createQuestionResult; var r = await _interpreter.Interpret(expr, ctx, dependencies); _dbContext.SaveChanges(); return(r.Match( created => Ok(created.Replies.PostId), notCreated => StatusCode(StatusCodes.Status500InternalServerError, "Question could not be created."),//todo return 500 (), invalidRequest => BadRequest("Invalid request."))); }