public IActionResult New(int petId) { try{ string UserId = _userManager.GetUserId(HttpContext.User); Watchlist watchlist = new Watchlist(); watchlist.PetId = petId; watchlist.UserId = UserId; if (!_repository.IsWatchlistExists(petId, UserId)) { _repository.Save(watchlist); } else { return(Content("Already exists in your watchlists")); } return(RedirectToAction(nameof(Index))); } catch (Exception ex) { throw ex; } }