public async Task <IActionResult> DeleteJobOffer(int?id)
        {
            if (id == null)
            {
                return(BadRequest());
            }
            JobOfferDto offer = await jobOfferFacade.GetByIdAsync(id.Value);

            if (offer == null)
            {
                return(NotFound());
            }
            var user = await userFacade.GetByIdAsync(int.Parse(User.Identity.Name));

            if (user.CompanyId != offer.CompanyId)
            {
                return(Forbid());
            }
            return(View(offer));
        }
Example #2
0
        public async Task <IActionResult> AddJobApplication(AddJobApplicationModel addModel)
        {
            if (!ModelState.IsValid)
            {
                throw new ArgumentException();
            }
            var jobOffer = await jobOfferFacade.GetByIdAsync(addModel.JobApplication.JobOfferId ?? 0);

            var user = await userFacade.GetByIdAsync(Int32.Parse(User.Identity.Name));

            var jobSeeker = await jobSeekerFacade.GetByIdAsync(user.JobSeekerId.Value);

            var jobApplication = new JobApplicationDto
            {
                ApplicantId = jobSeeker.Id,
                JobOfferId  = jobOffer.Id,
                Status      = Status.Unresolved,
                Answers     = addModel.JobApplication.Answers,
                Text        = addModel.JobApplication.Text
            };
            await jobApplicationFacade.ApplyToJobOfferAsync(jobApplication);

            return(RedirectToAction("Index"));
        }