public async Task <OrderReadDto> Handle(DeleteOrderCommand request, CancellationToken cancellationToken) { var result = await _orderRepo.DeleteOrderAsync(request.OrderId); if (result == null) { throw new ArgumentNullException(nameof(result)); } return(_mapper.Map <OrderReadDto>(result)); }
public async Task <IActionResult> DeleteOrder(int id) { var user = await _userManager.FindByEmailAsync(User.Identity.Name); Order order = await _orderRepo.GetOrderByIDAsync(id); // Safeguard to prevent user from cancelling another user's order. // Not sure how effective this is, though... if (order.UserID != user.Id) { return(RedirectToAction("Index", "Orders")); } await _orderRepo.DeleteOrderAsync(id); return(RedirectToAction("Index", "Orders")); }
public async Task <OrderReadDto> DeleteOrderAsync(int id) { Order result; try { result = await _orderRepo.DeleteOrderAsync(id); _logger.LogInformation($"[Success] Delete order at {DateTime.Now}"); } catch (Exception ex) { _logger.LogInformation($"[Error] Delete order at {DateTime.Now}: {ex.Message}"); throw new ArgumentNullException(nameof(result)); } return(_mapper.Map <OrderReadDto>(result)); }
public async Task <bool> DeleteOrderAsync(int orderId) { return(await _repo.DeleteOrderAsync(orderId)); }
public async Task <IActionResult> DeleteOrderAsync(long orderId) { return(await orderRepo.DeleteOrderAsync(orderId)); }
public async Task <IActionResult> DeleteOrderConfirmed(int id) { await _orderRepo.DeleteOrderAsync(id); return(RedirectToAction(nameof(RecentOrders))); }