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")); } }
public async Task <ActionResult> RemoveFromFavouriteAsync(int id, string returnUrl = "") { var user = await _userManager.GetUserAsync(User); if (user == null) { return(NotFound($"Unable to load user.")); } await _favoriteService.RemoveFromFavourite(user, PostType.Job, id.ToString()); return(PartialView("~/Views/Home/Partials/_QuickMenuPartial.cshtml")); }
public async Task <ActionResult> RemoveFromFavouriteAsync(int id, string returnUrl = "") { var user = await _userManager.GetUserAsync(User); if (user == null) { return(NotFound($"Unable to load user.")); } await _favoriteService.RemoveFromFavourite(user, PostType.Job, id.ToString()); if (!String.IsNullOrEmpty(returnUrl)) { return(Redirect(returnUrl)); } else { return(RedirectToAction("Index", "Home")); } }