public async Task Post([FromBody] WishList wish) { int userid = await GetUserId(); // Check if this wished item already exist in the wishlist var checkwish = await wishRepository.Wishes.FirstOrDefaultAsync(a => a.ItemId == wish.ItemId && a.UserId == userid); if (checkwish == null) { // If it does not exist add it to the list wish.UserId = userid; await wishRepository.SaveWishAsync(wish); } else { // If it exists delete it await wishRepository.DeleteWishAsync(checkwish); } }