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> ApplyWithResume(int jobId, JobsViewModel viewModel, string returnUrl, [FromServices] INotificationService _notifyService, [FromServices] IBaseService _baseService, [FromServices] IFavoritesService _favoriteService) { var user = await _userManager.GetUserAsync(User); if (user == null) { return(Redirect("/Identity/Account/Errors/AccessDenied")); } var result = await _jobsService.AddResumeFile(jobId, viewModel.resumeFilesId); if (result.Success) { await _favoriteService.AddToFavourite(user, PostType.Job, jobId.ToString()); _baseService.ToastNotify(ToastMessageState.Success, "Успешно", "Кандидатствахте по тази обява.", 3000); return(Redirect(returnUrl)); } else { await _notifyService.Create(result.FailureMessage, $"jobs/details/{jobId}", DateTime.Now, NotifyType.Danger, "fas fa-minus-circle", user); } if (!String.IsNullOrEmpty(returnUrl)) { return(Redirect(returnUrl)); } else { return(RedirectToAction("Index", "Home")); } }