public IActionResult Edit(int?id) { if (!id.HasValue) { return(View(new JobOfferEditViewModel())); } JobOfferEditViewModel model = jobOffersService.GetById(id.Value, HttpContext.Session.GetInt32("loggedUserId").Value); if (model == null) { return(RedirectToAction("List")); } return(View(model)); }
public IActionResult Accept(int?id) { if (!id.HasValue) { return(RedirectToAction("List", "UserJobOffers")); } UserApplicationEditViewModel model = userApplicationsService.GetById(id.Value); if (model == null) { return(RedirectToAction("List", "UserJobOffers")); } model.Status = ApplicationStatusEnum.Accepted; // User who created user application UserDetailsViewModel user = usersService.GetDetails(model.UserId); JobOfferEditViewModel jobOffer = jobOffersService.GetById(model.JobOfferId, user.Id); if (jobOffer == null) { return(RedirectToAction("List", "UserJobOffers")); } userApplicationsService.Update(model); emailService.SendAsync(new EmailViewModel { UserName = user.FullName, UserEmail = user.Email, Subject = "Application Accepted", Body = $"Your application for job {jobOffer.Title} has been accepted." }); return(RedirectToAction("Details", "UserJobOffers", new { id = model.JobOfferId })); }