public async Task <IActionResult> AddJobApplication(int jobOfferId) { var jobOffer = await jobOfferFacade.GetByIdWithQuestionsAsync(jobOfferId); var user = await userFacade.GetByIdAsync(Int32.Parse(User.Identity.Name)); var jobSeeker = await jobSeekerFacade.GetByIdAsync(user.JobSeekerId.Value); var model = new AddJobApplicationModel { JobOffer = jobOffer, JobApplication = new JobApplicationDto { ApplicantId = jobSeeker.Id, Applicant = jobSeeker, JobOfferId = jobOffer.Id, JobOffer = jobOffer, Status = Status.Unresolved, Answers = new JobApplicationAnswerDto[jobOffer.Questions.Count] } }; return(View(model)); }
public async Task <IActionResult> Index([FromQuery] int?page = 1, [FromQuery] string?skill = null, [FromQuery] bool?filterMySkill = false) { (int totalCount, IEnumerable <JobOfferDto> offers)model; if (User.IsInRole("Company")) { var user = await userFacade.GetByIdAsync(int.Parse(User.Identity.Name)); var offers = await jobOfferFacade.GetByCompanyIdAsync(user.CompanyId.Value); if (offers == null) { model = (0, new List <JobOfferDto>()); } else { model = (offers.Count(), offers); } } else if (User.IsInRole("JobSeeker") && filterMySkill.HasValue && filterMySkill.Value) { var user = await userFacade.GetByIdAsync(int.Parse(User.Identity.Name)); var skillTags = (await jobSeekerFacade.GetByIdAsync(user.JobSeekerId.Value)).Skills; model = await jobOfferFacade.GetAllAsync(PageSize, page ?? 1, skillTags); } else { model = await jobOfferFacade.GetAllAsync(PageSize, page ?? 1, skill == null?null : new List <string> { skill }); } var pagedModel = new PagedListViewModel <JobOfferDto>( new PaginationViewModel(page ?? 1, model.totalCount, PageSize), model.offers); return(View(pagedModel)); }