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") )); }
public async Task <IActionResult> CreateReply([FromBody] CreateReplyCmd createReplyCmd) { var expr = from createReplyResult in QuestionDomain.CreateReply(createReplyCmd.QuestionId, createReplyCmd.Body) let reply = createReplyResult.SafeCast <ReplyCreated>().Select(r => r) from checkLanguageResult in QuestionDomain.CheckLanguage(createReplyCmd.Body) from questionOwnerAckResult in QuestionDomain.AckQuestionOwner(createReplyCmd.QuestionId, "Some message") //de aici se poate extrage questionOwnerId from replyAuthorAckResult in QuestionDomain.AckReplyAuthor(createReplyCmd.replyId, "some notify message") //de aici se poate extrage replyAuthodId select new { createReplyResult, questionOwnerAckResult, replyAuthorAckResult }; //evenimentele returnate de workflow var ctx = new QuestionReadContext(new List <Post>()); var r = await _interpreter.Interpret(expr, ctx); await _dbContext.SaveChangesAsync(); return(r.createReplyResult.Match( Created => (IActionResult)OK(new Object()), NotCreated => BadRequest(new Object()) )); }
public async Task <IActionResult> CreateReplyAndAcknowledgement([FromBody] CreateReplyCmd createReplyCmd) { var expr = from createReplyResult in QuestionsDomain.CreateReply(createReplyCmd.QuestionId, createReplyCmd.AuthorUserId, createReplyCmd.QuestionOwnerId, createReplyCmd.Body) let reply = createReplyResult.SafeCast <ReplyCreated>().Select(r => r) from checkLanguageResult in QuestionsDomain.CheckLanguage(createReplyCmd.Body) from sendQuestionOwnerAcknowledgementResult in QuestionsDomain.SendQuestionOwnerAcknowledgement(createReplyCmd.QuestionId, createReplyCmd.QuestionOwnerId) from sendReplyAuthorAcknowledgementResult in QuestionsDomain.SendReplyAuthorAcknowledgement(createReplyCmd.AuthorUserId, createReplyCmd.QuestionOwnerId, reply) select new { createReplyResult, checkLanguageResult, sendQuestionOwnerAcknowledgementResult, sendReplyAuthorAcknowledgementResult }; var ctx = new QuestionReadContext(new List <Post>()); var r = await _interpreter.Interpret(expr, ctx); await _dbContext.SaveChangesAsync(); return(r.createReplyResult.Match( created => (IActionResult)Ok("Reply added"), notCreated => BadRequest("Reply not added"), whenInvalidRequest => BadRequest("Invalid request"))); }