Ejemplo n.º 1
0
        public IActionResult SendRegistration([FromBody] Register command)
        {
            try
            {
                var registration = new Register();
                using (var session = Store.LightweightSession())
                {
                    registration.Name    = command.Name;
                    registration.Address = command.Address;
                    registration.City    = command.City;
                    registration.Email   = command.Email;
                    session.Insert(registration);
                    session.SaveChanges();
                }

                RabbitMQClient client = new RabbitMQClient();
                client.SendRegistration(registration);
                client.Close();
                return(Ok(registration));
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
Ejemplo n.º 2
0
        public IHttpActionResult GenerateFibonacciSeries([FromBody] FibonacciRange req)
        {
            try
            {
                RabbitMQClient client = new RabbitMQClient();

                GenerateFibonacciPosRange fr = new GenerateFibonacciPosRange();
                BigInteger[] results         = new BigInteger[req.EndPosition - req.StartPosition + 1];
                results = fr.GetSeriesBetweenPosition(req.StartPosition, req.EndPosition);
                foreach (decimal num in results)
                {
                    req.result += num.ToString() + ", ";
                }
                //req.result = results.ToString();
                client.SendFibonacciSeries(req);

                client.Close();
            }
            catch (Exception)
            {
                return(StatusCode(HttpStatusCode.BadRequest));
            }

            return(Ok(req));
        }
Ejemplo n.º 3
0
        public IActionResult MakePayment([FromBody] CardPayment payment)
        {
            RabbitMQClient client = new RabbitMQClient();

            client.SendPayment(payment);
            client.Close();
            return(Ok(payment));
        }
Ejemplo n.º 4
0
        public IActionResult MakePayment([FromBody] PurchaseOrder payment)
        {
            RabbitMQClient client = new RabbitMQClient();

            client.SendPurchaseOrder(payment);
            client.Close();
            return(Ok(payment));
        }
Ejemplo n.º 5
0
        public async Task AddStock(StockDB stockDB)
        {
            // create a new queue for each operation

            RabbitMQClient client = new RabbitMQClient("Add_Queue", "stock.add");

            client.SendMethod(stockDB, "stock.add");
            client.Close();

            // save to dynamoDB
            await _context.SaveAsync(stockDB);
        }
Ejemplo n.º 6
0
        public async Task DeleteStock(StockDB stockDB)
        {
            // create a new queue for each operation

            RabbitMQClient client = new RabbitMQClient("Delete_Queue", "stock.delete");

            client.SendMethod(stockDB, "stock.delete");
            client.Close();

            // delete from dynamoDB
            await _context.DeleteAsync(stockDB);
        }
Ejemplo n.º 7
0
        public async Task UpdateStock(StockDB stockDB)
        {
            // create a new queue for each operation

            RabbitMQClient client = new RabbitMQClient("Patch_Queue", "stock.patch");

            client.SendMethod(stockDB, "stock.patch");
            client.Close();

            // update to dynamoDB
            await _context.SaveAsync(stockDB);
        }
Ejemplo n.º 8
0
 public IActionResult MakePayment([FromBody] CardPayment payment)
 {
     try
     {
         RabbitMQClient client = new RabbitMQClient();
         client.SendPayment(payment);
         client.Close();
     }
     catch (Exception)
     {
         return(BadRequest());
     }
     return(Ok(payment));
 }
 public IActionResult MakePayment([FromBody] PurchaseOrder order)
 {
     try
     {
         RabbitMQClient client = new RabbitMQClient();
         client.SendPurchaseOrder(order);
         client.Close();
     }
     catch (Exception)
     {
         return(BadRequest());
     }
     return(Ok(order));
 }
        public IHttpActionResult GetHistory([FromBody] HistoryRequest history)
        {
            try
            {
                RabbitMQClient client = new RabbitMQClient();
                client.SendHistory(history, "FSV.History");
                client.Close();
            }
            catch (Exception)
            {
                return(StatusCode(HttpStatusCode.BadRequest));
            }

            return(Ok(history));
        }
Ejemplo n.º 11
0
        public ActionResult AlertSubscription([FromBody] Subscription subscriber)
        {
            try
            {
                RabbitMQClient client = new RabbitMQClient(subscriber);
                client.AddAlert(subscriber);
                client.Close();
            }
            catch (Exception)
            {
                return(BadRequest());
            }

            return(Ok(subscriber));
        }
Ejemplo n.º 12
0
        public IHttpActionResult GetAuthenticate([FromBody] AuthenticationRequest authentication)
        {
            try
            {
                RabbitMQClient client = new RabbitMQClient();
                client.SendAuthentication(authentication, "FSV.Authentication");
                client.Close();
            }
            catch (Exception)
            {
                return(StatusCode(HttpStatusCode.BadRequest));
            }

            return(Ok(authentication));
        }
        public IActionResult MakePayment([FromBody] CardPayment cardPayment)
        {
            try
            {
                var client = new RabbitMQClient();
                client.SendPayment(cardPayment);
                client.Close();
            }
            catch (System.Exception)
            {
                return(StatusCode((int)HttpStatusCode.BadRequest));
            }

            return(Ok(cardPayment));
        }
        public IHttpActionResult MakePayment([FromBody] PurchaseOrder purchaseOrder)
        {
            try
            {
                RabbitMQClient client = new RabbitMQClient();
                client.SendPurchaseOrder(purchaseOrder);
                client.Close();
            }
            catch (Exception)
            {
                return(StatusCode(HttpStatusCode.BadRequest));
            }

            return(Ok(purchaseOrder));
        }
        public IHttpActionResult GetBalanceWithFees(BalanceRequest balance)
        {
            try
            {
                RabbitMQClient client = new RabbitMQClient();
                client.SendBalance(balance, "FSV.Balance");
                client.Close();
            }
            catch (Exception)
            {
                return(StatusCode(HttpStatusCode.BadRequest));
            }

            return(Ok(balance));
        }
Ejemplo n.º 16
0
        public IHttpActionResult MakePayment([FromBody] CardPayment payment)
        {
            try
            {
                // can use DI here as well/factory to get the client
                RabbitMQClient client = new RabbitMQClient();
                client.SendPayment(payment);
                client.Close();
            }
            catch (Exception)
            {
                return(StatusCode(HttpStatusCode.BadRequest));
            }

            return(Ok(payment));
        }
Ejemplo n.º 17
0
        public ActionResult SendSubscription(string bookId)
        {
            try
            {
                RabbitMQClient client = new RabbitMQClient(new Subscription {
                    BookId = bookId
                });
                client.SendAlert();
                client.Close();
            }
            catch (Exception)
            {
                return(BadRequest());
            }

            return(Ok());
        }
        public IHttpActionResult MakePayment([FromBody] CardPayment payment)
        {
            try
            {
                RabbitMQClient client = new RabbitMQClient();
                client.SendPayment(payment);

                //RabbitMQ closes the connection
                client.Close();
            }
            catch (Exception)
            {
                return(StatusCode(HttpStatusCode.BadRequest));
            }

            return(Ok(payment));
        }
Ejemplo n.º 19
0
        public IHttpActionResult GenerateFibonacciSeries([FromBody] Fibonacci req)
        {
            try
            {
                RabbitMQClient        client = new RabbitMQClient();
                FibonacciCalcNumAtPos fr     = new FibonacciCalcNumAtPos();
                BigInteger            result = fr.GetNumberAtPosition(req.Position);
                req.res = result;

                client.SendFibonacciNum(req);


                client.Close();
            }
            catch (Exception)
            {
                return(StatusCode(HttpStatusCode.BadRequest));
            }

            return(Ok(req));
        }
Ejemplo n.º 20
0
        public void RabbitMQClient_Test()
        {
            // Arrange
            RabbitMQClient MQClient = new RabbitMQClient("Test_Queue", "stock.test");
            StockDB        stockDB  = new StockDB
            {
                Name        = "TESTNAME",
                Price       = 123.99f,
                LastUpdated = System.DateTime.Now.ToString()
            };

            // Act
            MQClient.SendMethod(stockDB, "stock.test");
            var response = ReceiveMessage();

            // Assert
            Assert.AreEqual(stockDB.Name, response.Name);
            Assert.AreEqual(stockDB.Price, response.Price);
            Assert.AreEqual(stockDB.LastUpdated, response.LastUpdated);
            // Clean-up
            MQClient.Close();
        }