public Wishlist AddWishlist(WishlistDTO wishlistDTO) { Wishlist wishlist = Mapper.Map <WishlistDTO, Wishlist>(wishlistDTO); wishlistRepository.AddWishlist(wishlist); return(null); }
public async Task <ActionResult> PostWishlist([Bind("ID,ProductID,CartProductQuantity")] Wishlist wishlist) { if (ModelState.IsValid) { await _wishlist.SetWishlistTotal(wishlist); //if wishlist has the same item that was added to the cart, remove the item from the wishlist if (await _wishlist.HasSameItem(wishlist.ProductID)) { await IncreaseProductQuantity(wishlist, wishlist.WishlistProductQuantity); return(Ok(GetWishlist(wishlist.ProductID))); } _wishlist.AddWishlist(wishlist); await _wishlist.SaveWishlist(); return(Ok(GetWishlist(wishlist.ProductID))); } return(BadRequest()); }
public async Task <IActionResult> Create([Bind("ID,ProductID,WishlistProductQuantity")] Wishlist wishlist) { if (ModelState.IsValid) { await _wishlist.SetWishlistTotal(wishlist); //if wishlist has the same item that was created , increase the quantity of that item. if (await _wishlist.HasSameItem(wishlist.ProductID)) { await IncreaseProductQuantity(wishlist, wishlist.WishlistProductQuantity); return(RedirectToAction(nameof(Index))); } _wishlist.AddWishlist(wishlist); await _wishlist.SaveWishlist(); return(RedirectToAction(nameof(Index))); } return(View(wishlist)); }