public async Task <IActionResult> PatchBasketItem(string basketId, string itemId, [FromBody] JsonPatchDocument <Item> jsonPatchDocument) { try { var basketItem = await this.getBasketItemById .Execute(GetBasketItemByIdRequest.Create(basketId, itemId)); if (null == basketItem) { return(NotFound()); } jsonPatchDocument.ApplyTo(basketItem); await this.updateBasketItem .Execute(UpdateBasketItemRequest.Create(basketId, basketItem)); return(new ObjectResult(basketItem)); } catch (Exception e) { this.logger.Error(e.Message); return(BadRequest()); } }
public async Task <IActionResult> GetBasketItemById(string basketId, string itemId) { try { if (string.IsNullOrEmpty(basketId) || string.IsNullOrEmpty(itemId)) { return(BadRequest()); } var result = await this.getBasketItemById .Execute(GetBasketItemByIdRequest.Create(basketId, itemId)); if (null == result) { return(NotFound()); } return(Ok(result)); } catch (Exception e) { this.logger.Error(e.Message); return(BadRequest()); } }