public async Task <IActionResult> CreateAndNotifyReply([FromBody] CmdReply createNotifyCmd) { QuestWrite ctx = new QuestWrite( new EFList <Post>(_dbContext.Post), new EFList <User>(_dbContext.User)); var dependencies = new QuestDependencies(); dependencies.GenerateConfirmationToken = () => Guid.NewGuid().ToString(); dependencies.SendConfirmationEmail = SendEmail; var expr = from createReplyResult in QuestDomain.CreateReply(createNotifyCmd) let user = createReplyResult.SafeCast <ResultReply.ReplyCreated>().Select(p => p.Author) let notifyReplyCmd = new NotifyCmdReply(user) from NotifyReplyResult in QuestDomain.NotifyReply(notifyReplyCmd) select new { createReplyResult }; var r = await _interpreter.Interpret(expr, ctx, dependencies); _dbContext.Post.Add(new Post { PostTypeId = 2, PostText = createNotifyCmd.Body, PostedBy = new Guid("f505c32f-3573-4459-8112-af8276d3e919"), PostId = createNotifyCmd.QuestionId }); await _dbContext.SaveChangesAsync(); return(r.createReplyResult.Match( created => (IActionResult)Ok(created.Answer.PostId), notCreated => StatusCode(StatusCodes.Status500InternalServerError, "Reply could not be created."),//todo return 500 (), invalidRequest => BadRequest("Invalid request."))); }
static void Main(String[] args) { BloocoinClient blc = new BloocoinClient(); String[] bloostamp; if (!blc.bloostampExists()) // Bloostamp not found, create a new one. { do { bloostamp = blc.generateBloostamp().Split(':'); } while (!blc.register(bloostamp[0], bloostamp[1])); blc.writeBloostamp(bloostamp[0], bloostamp[1]); Console.WriteLine("New bloostamp created!"); } else { bloostamp = blc.readBloostamp().Split(':'); // Bloostamp found, read it. } blc.setAddrAndPwd(bloostamp[0], bloostamp[1]); try { // Get current coin count. CmdReply <int> coins = blc.getReply <int>("my_coins"); // Get all transactions for this account. CmdReply <List <Transaction> > trans = blc.getReply <List <Transaction> >("transactions"); Transaction last = (trans.payload["transactions"].Count != 0) ? trans.payload["transactions"].Last() : new Transaction(); String sLast = (last.to == blc.getAddress()) ? "From: " : "To: "; sLast += (last.to == blc.getAddress()) ? last.from : last.to; sLast += " Amount: " + last.amount; // Print output :D Console.WriteLine("Address: {0}", blc.getAddress()); Console.WriteLine("Pwd: {0}", blc.getPwd()); Console.WriteLine("Coins: {0}", coins.payload["amount"]); Console.WriteLine("Transaction count: {0}", trans.payload["transactions"].Count); Console.WriteLine("Last Transaction: {0}", sLast); } catch (ki113d.CsBloocoin.Exceptions.ConnectionTimeoutException ohShit) { Console.WriteLine("ConnectionTimeoutException caught: {0}", ohShit.ErrorMessage); } }
public static Port <IResultReply> CreateReply(CmdReply command) => NewPort <CmdReply, IResultReply>(command);