public async Task <ActionResult> UpdateFavourite(int id, string returnUrl, [FromServices] IFavoritesService _favoriteService) { var user = await _userManager.GetUserAsync(User); if (user == null) { return(Redirect("/Identity/Account/Errors/AccessDenied")); } if (!(await _favoriteService.isInFavourite(user, PostType.Company, id))) { await _favoriteService.AddToFavourite(user, PostType.Company, id.ToString()); } else { await _favoriteService.RemoveFromFavourite(user, PostType.Company, id.ToString()); } if (!String.IsNullOrEmpty(returnUrl)) { return(Redirect(returnUrl)); } else { return(RedirectToAction("Index", "Home")); } }