Ejemplo n.º 1
0
        public JsonResult AddToWishList(int productId)
        {
            var userId = User.Identity.GetUserId();

            _wishListService.Add(AutoMapper.Mapper.Map <WishListDto>(new { userId = userId, productId = productId, productName = "", productPrice = 0, productPhoto = "" }));
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
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 }));
        }
Ejemplo n.º 3
0
 public Task <WishListViewModel> Add(string title, string author, string isbn)
 {
     return(_wishListService.Add(new AddWishListBindingModel
     {
         BookTitle = title,
         BookAuthor = author,
         BookIsbn = isbn
     }));
 }
        public ActionResult <OutputDtoQueryWishLists> AddItemToWishlist(int uservId, int itemId)
        {
            try
            {
                var response = _wishListService.Add(uservId, itemId);

                return(Ok(response));
            }
            catch (DuplicateSqlPrimaryException e)
            {
                return(BadRequest(new { message = e.Message }));
            }
        }