예제 #1
0
        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 }));
        }
예제 #2
0
        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
            }));
        }
예제 #3
0
        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();
        }
예제 #4
0
        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));
        }