/// <summary> /// Executes the delete item from basket use case. /// This execution triggers a domain event BasketUpdated in order to be consumed by the interested parties. /// </summary> /// <param name="request">The request with the basket item data to delete.</param> public async Task Execute(DeleteBasketItemRequest request) { try { await this.basketsRepository.DeleteItem(request.BasketId, request.ItemId); await this.PublishBasketDeleted(request.BasketId); } catch (Exception ex) { this.logger.Error( $"{nameof(InsertBasket)}.{nameof(Execute)}", ex); throw; } }
public async Task <IActionResult> DeleteBasketItemById(string basketId, string itemId) { try { if (string.IsNullOrEmpty(basketId) || string.IsNullOrEmpty(itemId)) { return(this.BadRequest()); } await this.deleteBasketItem .Execute(DeleteBasketItemRequest.Create(basketId, itemId)); return(NoContent()); } catch (Exception e) { this.logger.Error(e.Message); return(BadRequest()); } }