예제 #1
0
        public async Task <IActionResult> ChangeProductQuantityAsync(string id, string productId, int quantity)
        {
            var command       = new ChangeProductQuantityCommand(id, productId, quantity);
            var commandResult = await mediator.Send(command);

            if (commandResult.WasSuccessful)
            {
                return(RedirectToAction(nameof(DetailsAsync), new { id }));
            }

            var viewModel = await GetCartDetailsViewModel(id);

            viewModel.AddMessage(MessageModel.Alert(commandResult.BrokenRules.First().Message));

            return(View(nameof(DetailsAsync), viewModel));
        }
예제 #2
0
        public async Task <IActionResult> CreateAsync(string customerId)
        {
            var command       = new CreateCartCommand(customerId);
            var commandResult = await mediator.Send(command);

            if (commandResult.WasSuccessful)
            {
                return(RedirectToAction(nameof(IndexAsync)));
            }

            var viewModel = await GetIndexViewModel();

            viewModel.AddMessage(MessageModel.Alert(commandResult.BrokenRules.First().Message));

            return(View(nameof(IndexAsync), viewModel));
        }