コード例 #1
0
        public ActionResult <Account> postAccount(Account account)
        {
            using (var conn = factory.CreateConnection())
                using (var channel = conn.CreateModel())
                {
                    _context.Create(account);
                    var data = Encoding.UTF8.GetBytes(account.ToString());
                    channel.QueueDeclare("queue1", false, false, false, null);
                    // publish to the "default exchange", with the queue name as the routing key
                    channel.BasicPublish("", "queue1", null, data);
                }



            return(CreatedAtAction("GetAccount", new { id = account.UserId }, account));
        }
コード例 #2
0
        public async Task <IActionResult> Account([FromBody] Account account)
        {
            //check if valid
            if (!ModelState.IsValid && account != null)
            {
                return(BadRequest(ModelState));
            }

            //check if username already exists
            Account userToVerify = await Task.FromResult(_context.Get(account.Name));

            if (userToVerify == null)
            {
                await Task.FromResult(_context.Create(account));

                return(new OkObjectResult("Account created"));
            }

            return(NotFound());
        }