예제 #1
0
        private async Task <IEnumerable <Inventory> > HandleCommandAsync(GetAllInventory command)
        {
            var result = await repository.GetAllAsync();

            Console.WriteLine($"Command Handled : {command.GetType().Name}");

            return(result);
        }
        public async Task <IActionResult> GetAllInventory()
        {
            var command = new GetAllInventory();

            try
            {
                var response = await commandExecutor.RunAsync <IEnumerable <Inventory> >(command);

                return(Ok(response));
            }
            catch (System.Exception ex)
            {
                string errorMessage = "Unable to save changes. " +
                                      "Try again, and if the problem persists " +
                                      "see your system administrator.";
                Log.Error(ex, errorMessage);
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }