public IActionResult DeleteCartItem(WishListItemDTO wishlistItemDTO) { //List<ProdcutDesignDTO> prdList = JsonConvert.DeserializeObject<List<ProdcutDesignDTO>>(productDesignList); var prr = cartService.DeleteFromWishList(wishlistItemDTO.cartItemId, wishlistItemDTO.userId); return(Ok(new MessaageCommonResponse() { message = prr })); }
/// <summary> /// Allows you to convert the current wish list item object to the DTO equivalent for use with the REST API /// </summary> /// <returns>A new instance of WishListItemDTO</returns> public WishListItemDTO ToDto() { var dto = new WishListItemDTO(); dto.Id = Id; dto.StoreId = StoreId; dto.CustomerId = CustomerId; dto.LastUpdatedUtc = LastUpdatedUtc; dto.ProductId = ProductId ?? string.Empty; dto.Quantity = Quantity; foreach (var op in SelectionData.OptionSelectionList) { dto.SelectionData.Add(op.ToDto()); } return(dto); }
//DTO public WishListItemDTO ToDto() { WishListItemDTO dto = new WishListItemDTO(); dto.Id = this.Id; dto.StoreId = this.StoreId; dto.CustomerId = this.CustomerId; dto.LastUpdatedUtc = this.LastUpdatedUtc; dto.ProductId = this.ProductId ?? string.Empty; dto.Quantity = this.Quantity; foreach (Catalog.OptionSelection op in this.SelectionData) { dto.SelectionData.Add(op.ToDto()); } return(dto); }
/// <summary> /// Allows the REST API to create or update a wish list item. /// </summary> /// <param name="parameters"> /// Parameters passed in the URL of the REST API call. Only one parameter is expected, which is /// the ID of the wish list item, but only when updating. /// </param> /// <param name="querystring">Name/value pairs from the REST API call querystring. This is not used in this method.</param> /// <param name="postdata">Serialized (JSON) version of the WishListItemDTO object</param> /// <returns>WishListItemDTO - Serialized (JSON) version of the wish list item</returns> public override string PostAction(string parameters, NameValueCollection querystring, string postdata) { var data = string.Empty; long id = 0; long.TryParse(FirstParameter(parameters), out id); var response = new ApiResponse <WishListItemDTO>(); WishListItemDTO postedItem = null; try { postedItem = Json.ObjectFromJson <WishListItemDTO>(postdata); } catch (Exception ex) { response.Errors.Add(new ApiError("EXCEPTION", ex.Message)); return(Json.ObjectToJson(response)); } var item = new WishListItem(); item.FromDto(postedItem); if (id < 1) { if (HccApp.CatalogServices.WishListItems.Create(item)) { id = item.Id; } } else { HccApp.CatalogServices.WishListItems.Update(item); } var resultItem = HccApp.CatalogServices.WishListItems.Find(id); if (resultItem != null) { response.Content = resultItem.ToDto(); } data = Json.ObjectToJson(response); return(data); }
public void WishList_CreateUpdateDelete() { //Create API Proxy. var proxy = CreateApiProxy(); //Create WishList var item = new WishListItemDTO { ProductId = "EBF3029C-D673-49DA-958A-432C65B16D4C", Quantity = 1, CustomerId = "2" }; // Create var create1Response = proxy.WishListItemsCreate(item); CheckErrors(create1Response); // Update item = create1Response.Content; item.Quantity = 10; var updateResponse = proxy.WishListItemsUpdate(item); CheckErrors(updateResponse); Assert.AreEqual(create1Response.Content.Quantity, updateResponse.Content.Quantity); var findResponse = proxy.WishListItemsFind(updateResponse.Content.Id); CheckErrors(findResponse); Assert.AreEqual(updateResponse.Content.Quantity, findResponse.Content.Quantity); // Delete var delete1Response = proxy.WishListItemsDelete(create1Response.Content.Id); CheckErrors(delete1Response); Assert.IsTrue(delete1Response.Content); }
/// <summary> /// Allows you to populate the current wish list item object using a WishListItemDTO instance /// </summary> /// <param name="dto">An instance of the wish list item from the REST API</param> public void FromDto(WishListItemDTO dto) { if (dto == null) { return; } Id = dto.Id; StoreId = dto.StoreId; CustomerId = dto.CustomerId; LastUpdatedUtc = dto.LastUpdatedUtc; ProductId = dto.ProductId ?? string.Empty; Quantity = dto.Quantity; SelectionData.Clear(); if (dto.SelectionData != null) { foreach (var op in dto.SelectionData) { var o = new OptionSelection(); o.FromDto(op); SelectionData.OptionSelectionList.Add(o); } } }
public void FromDto(WishListItemDTO dto) { if (dto == null) { return; } this.Id = dto.Id; this.StoreId = dto.StoreId; this.CustomerId = dto.CustomerId; this.LastUpdatedUtc = dto.LastUpdatedUtc; this.ProductId = dto.ProductId ?? string.Empty; this.Quantity = dto.Quantity; this.SelectionData.Clear(); if (dto.SelectionData != null) { foreach (OptionSelectionDTO op in dto.SelectionData) { Catalog.OptionSelection o = new Catalog.OptionSelection(); o.FromDto(op); this.SelectionData.Add(o); } } }