public async Task <ActionResult> Save(int id, JobOfferDetailsViewModel model) { var toUpdate = context.JobOffer .Include(x => x.Responsibility) .ThenInclude(x => x.User) .FirstOrDefault(jobOffer => jobOffer.IdJobOffer == id); if (toUpdate != null && User.CanManageJobOffer(toUpdate)) { toUpdate.JobTitle = model.JobOfferModel.JobTitle; toUpdate.Description = model.JobOfferModel.Description; await context.SaveChangesAsync(); } return(RedirectToAction("Details", new { id = id, isEditing = true })); }
public IActionResult Details(int?id) { if (!id.HasValue) { return(RedirectToAction("List")); } JobOfferDetailsViewModel model = jobOffersService.GetByIdWithUserApplications(id.Value, HttpContext.Session.GetInt32("loggedUserId").Value); if (model == null) { return(RedirectToAction("List")); } return(View(model)); }
public IActionResult Details(int id, bool isEditing) { var baseModel = jobOffers.Where(offer => offer.Id == id).FirstOrDefault(); if (baseModel.Description == null) { baseModel.GetJobOfferDetails(context); } var model = new JobOfferDetailsViewModel { JobOfferModel = baseModel, IsEditing = isEditing && User.CanManageJobOffer(baseModel) }; return(View(model)); }
//Details public async Task <IActionResult> Details(int id) { bool isIngroup = await CheckIfUserIsAnAdmin(); if (isIngroup) { User.Identities.First().AddClaim(new Claim(ClaimTypes.Role, "Admins")); } var offer = _context.JobOffers.First(x => x.Id == id); if (offer == null) { return(new StatusCodeResult((int)HttpStatusCode.NotFound)); } _context.Entry(offer).Reference(f => f.Company).Load(); JobOfferDetailsViewModel model = new JobOfferDetailsViewModel { Offer = offer }; model.Applications = _context.JobApplications.Where(x => x.OfferId == id).ToList(); return(View(model)); }
public IActionResult Apply(int?jobOfferId) { if (!jobOfferId.HasValue) { return(RedirectToAction("List", "UserJobOffers")); } UserDetailsViewModel user = usersService.GetDetails(HttpContext.Session.GetInt32("loggedUserId").Value); JobOfferDetailsViewModel jobOffer = jobOffersService.GetDetails(jobOfferId.Value, user.Id); if (jobOffer == null) { return(RedirectToAction("List", "UserJobOffers")); } UserApplicationEditViewModel model = new UserApplicationEditViewModel { UserId = user.Id, // AuthenticationService.LoggedUser.Id, JobOfferId = jobOffer.Id, // jobOfferId.Value Status = ApplicationStatusEnum.Pending }; userApplicationsService.Insert(model); // Send email emailService.SendAsync(new EmailViewModel { UserName = jobOffer.User.FullName, UserEmail = jobOffer.User.Email, Subject = "New Application", Body = $"{user.FullName} applied for job {jobOffer.Title}" }); return(RedirectToAction("Details", "UserJobOffers", new { id = jobOfferId })); }
public static void CreateJobOfferDetailsViewModel() { if (_jobOfferDetailsViewModel == null) { _jobOfferDetailsViewModel = new JobOfferDetailsViewModel(); } }
public static void ClearJobOfferDetailsViewModel() { _jobOfferDetailsViewModel.Cleanup(); _jobOfferDetailsViewModel = null; }