Esempio n. 1
0
        public IActionResult SetProductByOrder([FromBody] SetProductModel model)
        {
            try
            {
                var userId     = 2;
                var productMap = _mapper.Map <SetProductDto>(model);

                var command = new SetProductCommand(productMap, userId);
                _commandDispatcher.DispatchCommand(command);

                return(new OkObjectResult("OK"));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Esempio n. 2
0
        public IActionResult CreateStock()
        {
            var createCommand = new CreateStockCommand(Guid.NewGuid(), -1, "Gold", 0.221, 3.454);

            _commandDispatcher.DispatchCommand(createCommand);

            return(new OkObjectResult("OK"));
        }
        public IActionResult UpdateDownStockValueAsync()
        {
            var aggregateId = Guid.Parse("7F676FE2-1643-4556-8861-F66791957AA1");

            //var result =  FetchEventsByAggregateAsync(aggregateId, -1).GetAwaiter();

            var command = new DownStockCommand(aggregateId, 5.442, 1);

            _commandDispatcher.DispatchCommand(command);

            return(new OkObjectResult("OK"));
        }
        public IActionResult EndOrderByID([FromBody] CompleteOrderModel model)
        {
            try
            {
                var command = new CompleteOrderCommand(model.orderId);
                _commandDispatcher.DispatchCommand(command);

                return(new OkObjectResult("Order complete successfully!"));
            }
            catch (AppException ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public IActionResult PersistEmployee([FromBody] PersistEmployeeModel model)
        {
            try
            {
                var persistMap = _mapper.Map <PersistEmployeeDto>(model);

                var command = new PersistEmployeeCommand(persistMap);
                _commandDispatcher.DispatchCommand(command);

                return(new OkObjectResult("OK"));
            }
            catch (AppException ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public IActionResult updateUserAsync([FromBody] UpdateUserModel model)
        {
            try
            {
                int id      = 17;
                var userMap = _mapper.Map <UpdateUserDto>(model);

                var command = new UpdateUserCommand(id, userMap);
                _commandDispatcher.DispatchCommand(command);

                return(new OkObjectResult("ОК"));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Esempio n. 7
0
        public IActionResult CreateOrder([FromBody] CreateOrderModel order)
        {
            try
            {
                var userId   = 17;
                var orderMap = _mapper.Map <AddOrderDto>(order);

                var command = new CreateOrderCommand(orderMap, userId);
                _commandDispatcher.DispatchCommand(command);

                return(new OkObjectResult("OK"));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Esempio n. 8
0
        public IActionResult AddToLink([FromBody] OrdersLinkModel model)
        {
            try
            {
                int        rmId   = 17;
                List <int> orders = new List <int>();
                orders = model.Orders;

                var command = new AddToLinkCommand(orders, rmId);
                _commandDispatcher.DispatchCommand(command);

                return(new OkObjectResult("Orders to Link added successfully!"));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Esempio n. 9
0
        public void Run()
        {
            this.databaseService.InitializeDatabase();

            while (true)
            {
                try
                {
                    string   input  = Console.ReadLine().Trim();
                    string[] data   = input.Split();
                    string   result = commandDispatcher.DispatchCommand(data);
                    Console.WriteLine(result.Trim());
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
        }
Esempio n. 10
0
 public void ProcessCommand(ICommand command)
 {
     _dispatcher.DispatchCommand(command);
 }
Esempio n. 11
0
 public async Task Consume(ConsumeContext <TCommand> context)
 {
     _commandDispatcher.DispatchCommand(context.Message);
 }