public async Task <ActionResult> Delete(int id)
        {
            var offer = await JobOfferFacade.GetOffer(id);

            var currentEmployer = await EmployerFacade.GetEmployerByEmail(User.Identity.Name);

            if (currentEmployer.Id != offer.EmployerId)
            {
                throw new ArgumentException();
            }

            return(View(offer));
        }
        public async Task <ActionResult> ApplicationsByJobOffer(int id)
        {
            var emoloyer = await EmployerFacade.GetEmployerByEmail(User.Identity.Name);

            var job = await JobOfferFacade.GetOffer(id);

            if (job.Employer.Id != emoloyer.Id)
            {
                throw new ArgumentException();
            }

            var aplications = await JobApplicationFacade.GetByJobOffer(id);

            return(View("Index", aplications.Items));
        }
        public async Task <ActionResult> Create(int jobOfferId)
        {
            var offer = await JobOfferFacade.GetOffer(jobOfferId);

            var user = User.Identity.Name.IsNullOrEmpty()
                ? new ApplicantDto()
                : await UserFacade.GetUserByEmail(User.Identity.Name);

            var model = new JobApplicationCreateDto
            {
                Applicant  = user,
                JobOffer   = offer,
                JobOfferId = offer.Id
            };

            return(View(model));
        }
        public async Task <ActionResult> Edit(int id)
        {
            var jobOfferCreateDto = new JobOfferCreateDto(await JobOfferFacade.GetOffer(id));
            var currentEmployer   = await EmployerFacade.GetEmployerByEmail(User.Identity.Name);

            if (currentEmployer.Id != jobOfferCreateDto.EmployerId)
            {
                throw new ArgumentException();
            }

            var model = new JobOfferCreateViewModel
            {
                AllSkills         = await SkillSelectListHelper.Get(),
                Employer          = currentEmployer,
                JobOfferCreateDto = jobOfferCreateDto
            };

            return(View(model));
        }
        public async Task <ActionResult> Create(JobApplicationCreateDto application)
        {
            if (ModelState.IsValid)
            {
                await JobApplicationFacade.CreateApplication(application);

                return(RedirectToAction("Details", "JobOffer", new { id = application.JobOfferId }));
            }

            var offer = await JobOfferFacade.GetOffer(application.JobOfferId);

            application.JobOffer   = offer;
            application.JobOfferId = offer.Id;
            application.Applicant  = User.Identity.Name.IsNullOrEmpty()
                ? new ApplicantDto()
                : await UserFacade.GetUserByEmail(User.Identity.Name);


            return(View(application));
        }
        public async Task <ActionResult> Details(int id)
        {
            var offer = await JobOfferFacade.GetOffer(id);

            return(View(offer));
        }