public IActionResult ToggleFavorites(int materialId) { var loggedUser = _userService.FindByIdentityUserId(User.FindFirstValue(ClaimTypes.NameIdentifier)); var material = _service.GetMaterial(materialId); if (material == null) { return(RedirectToAction("ResourceNotFound", "Error", new { error = "materiaĆ o podanym Id nie istnieje." })); } _service.ToggleFavorite(material, loggedUser); return(RedirectToAction("Material", new { @materialId = materialId })); }