예제 #1
0
        public async Task RemoveFromWishlistAsync_WithValidData_ShouldRemoveCorrectly()
        {
            var userId = "userId";
            var adId   = "adId";

            await service.AddToWishlistAsync(userId, adId);

            await service.RemoveFromWishlistAsync(userId, adId);

            var actualCount   = context.UsersAdvertisementsWishlist.Count();
            var expectedCount = 0;

            Assert.AreEqual(expectedCount, actualCount);
        }
예제 #2
0
        public async Task <IActionResult> RemoveFromWishlist(string adId)
        {
            if (!advertisementService.Contains(adId))
            {
                return(Redirect("/Home/Index"));
            }

            var ad = await advertisementService.GetByIdAsync(adId);

            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);

            if (userId == ad.UserId)
            {
                return(Redirect($"/Advertisement/Details?id={adId}"));
            }

            await userAdWishlistService.RemoveFromWishlistAsync(userId, adId);

            return(Redirect($"/Advertisement/Details?id={adId}"));
        }