Exemple #1
0
        public async Task <IActionResult> CreateTenantAsyncAndInviteAdmin([FromBody] CreateReplyCmd createReplyCmd)
        {
            var expr = from createReplyResult in QuestionDomain.CreateReply(createReplyCmd.QuestionId, createReplyCmd.AuthorQuestionId, createReplyCmd.QuestionOwnerId, createReplyCmd.Body)
                       let reply = createReplyResult.SafeCast <ReplyCreated>().Select(re => re)
                                   from checkLanguageResult in QuestionDomain.CheckLanguage(createReplyCmd.Body)
                                   from ownerAcknowledgementResult in QuestionDomain.QuestionOwnerAcknowledgement(createReplyCmd.QuestionId, createReplyCmd.QuestionOwnerId)
                                   from authorAcknowledgementResult in QuestionDomain.ReplyAuthorAcknowledgement(createReplyCmd.QuestionId, createReplyCmd.AuthorQuestionId, reply)
                                   select new { createReplyResult, checkLanguageResult, ownerAcknowledgementResult, authorAcknowledgementResult };

            var ctx = new QuestionReadContext(new List <Post>());
            var r   = await _interpreter.Interpret(expr, ctx);

            return(r.createReplyResult.Match(
                       created => (IActionResult)Ok("Reply added"),
                       notCreated => BadRequest("Reply not added")
                       ));
        }