Пример #1
0
        public IActionResult AddToWishList(int productId)
        {
            var productToBeAdded = _productService.GetById(productId);
            var wishList         = _wishListSessionService.GetWishList();

            _wishListService.AddToWishList(wishList, productToBeAdded.Data);
            _wishListSessionService.SetWishList(wishList);
            //TempData.Add("message", String.Format("{0} sepete eklendi", productToBeAdded.Name));
            return(RedirectToAction("Index", "Home"));
        }
Пример #2
0
        public async Task <IActionResult> AddToWishList(int productId)
        {
            var currentUser = await _userManager.GetUserAsync(HttpContext.User);

            if (currentUser == null)
            {
                TempData["SM"] = "Вы не авторизованы";
                return(RedirectToAction("Index", "Home"));
            }
            await _wishListService.AddToWishList(currentUser.Id, productId);

            TempData["SM"] = "Товар добавлен";
            return(RedirectToAction("Details", "Product", new { id = productId }));
        }
Пример #3
0
        public JsonResult AddToWishList(int productId)
        {
            if (!ModelState.IsValid)
            {
                TempData["Notification"] = "Something Wrong";
                return(Json(new { success = false, JsonRequestBehavior.AllowGet }));
            }
            try
            {
                var userId = User.Identity.GetUserId();
                _wishListService.AddToWishList(productId, userId);
                TempData["Notification"] = "Successfully";

                return(Json(new { success = true, JsonRequestBehavior.AllowGet }));
            }
            catch (Exception e)
            {
                return(Json(new { success = false, JsonRequestBehavior.AllowGet }));
            }
        }
Пример #4
0
 public IActionResult AddToWishListConfirmed(string id, string note)
 {
     try
     {
         var bookDto = _bookService.Get(id);
         var wlDto   = new WishListItemDto
         {
             BookId = bookDto.Id,
             UserId = User.GetUserId(),
             Note   = note
         };
         _service.AddToWishList(wlDto);
         return(Redirect("/WishList"));
     }
     catch (Exception e)
     {
         return(View("Error", new ErrorViewModel
         {
             RequestId = Request.HttpContext.TraceIdentifier,
             Exception = e
         }));
     }
 }
Пример #5
0
 public ActionResult AddToWishList(string Id)
 {
     WishListService.AddToWishList(this.HttpContext, Id);
     return(RedirectToAction("Index"));
 }
Пример #6
0
 public IActionResult AddToWishList([Required][FromBody] int productId)
 {
     _wishListService.AddToWishList(productId, CurrentUserId);
     return(Ok());
 }