public async Task <IActionResult> CreateQuestionAndSendEmail([FromBody] ValidateQuestionCmd validateQuestionCmd) { QuestionWriteContext ctx = new QuestionWriteContext(new EFList <Post>(_dbContext.Post)); var dependencies = new QuestionDependencies(); var expr = from validateQuestionResult in QuestionDomain.ValidateQuestion(validateQuestionCmd) let post = validateQuestionResult.SafeCast <QuestionValidated>().Select(p => p.Post) select new { validateQuestionResult }; var r = await _interpreter.Interpret(expr, ctx, dependencies); _dbContext.SaveChanges(); return(r.validateQuestionResult.Match( created => (IActionResult)Ok(created.Post.PostId), notCreated => StatusCode(StatusCodes.Status500InternalServerError, "Question could not be created."), invalidRequest => BadRequest("Invalid request."))); }