public IActionResult AddToWishList(WishListDTO model) { if (string.IsNullOrEmpty(model.UserId) || string.IsNullOrEmpty(model.BookId) || string.IsNullOrEmpty(model.Name)) { return(RedirectToAction("Error")); } WishListDTO item = new WishListDTO { BookId = model.BookId, UserId = model.UserId, Name = model.Name }; List <WishListDTO> wishListToFind = _wlService.Get(new WishListFullFilter { BookId = model.BookId, UserId = model.UserId, Name = model.Name }).ToList(); if (wishListToFind.Any()) { return(RedirectToAction("GetBookInfo", "Home", new { id = model.BookId })); } _wlService.Add(item); return(RedirectToAction("GetBookInfo", "Home", new { id = model.BookId })); }
public IActionResult AddToWishList(WishListDTO wishlistDto) { //List<ProdcutDesignDTO> prdList = JsonConvert.DeserializeObject<List<ProdcutDesignDTO>>(productDesignList); string prr = cartService.AddToWishList(wishlistDto.userId, wishlistDto.productId); return(Ok(new MessaageCommonResponse() { message = prr })); }
public async Task AddToWhishList([FromForm] WishListDTO wishListDto) { var whishList = _mapper.Map <WishListDTO, WhishListItem>(wishListDto); whishList = new WhishListItem { ProductId = wishListDto.ProductId, UserId = wishListDto.UserId }; Database.WishListPrepository.Add(whishList); await Database.SaveAsync(); }
public IActionResult Create([Bind("wishListName,description")] WishListDTO WishList) { if (ModelState.IsValid) { HttpClient client = _scotchesAPI.InitializeClient(); var content = new StringContent(JsonConvert.SerializeObject(WishList, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }), Encoding.UTF8, "application/json"); HttpResponseMessage res = client.PostAsync("/api/wishlists", content).Result; if (res.IsSuccessStatusCode) { return(RedirectToAction("Index")); } } return(View(WishList)); }