Example #1
0
 public ActionResult Delete(int id)
 {
     if (!ModelState.IsValid)
     {
         TempData["WishList"] = "SomeThing Wrong!!!";
         return(RedirectToAction("Index"));
     }
     try
     {
         var list = _wishListService.DeleteWishList(id);
         TempData["WishList"] = "Delete Successfully !!!";
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         TempData["WishList"] = "SomeThing Wrong!!!";
         return(RedirectToAction("Index"));
     }
 }
        public async Task <IActionResult> DeleteWishItem(int bookId)
        {
            var userId = GetUserId();

            if (userId == "error")
            {
                return(Unauthorized(new { message = "unauthorized" }));
            }
            var wishItemInDB = await _wishListService.GetWishItem(bookId, userId);

            if (wishItemInDB == null)
            {
                return(NotFound(new { message = "Sách không tồn tại trong wishlist của bạn" }));
            }
            var result = await _wishListService.DeleteWishList(bookId, userId);

            if (!result)
            {
                return(BadRequest(new { message = "Có lỗi trong quá trình xóa dữ liệu" }));
            }
            return(Ok(new { message = "Sách được xóa thành công" }));
        }