public async Task <ActionResult> OffersOfCurrentEmployer()
        {
            var employer = await EmployerFacade.GetEmployerByEmail(User.Identity.Name);

            var offers = await JobOfferFacade.GetAllOffersOfEmployer(employer.Id);

            return(View("Index", offers));
        }
        public async Task <ActionResult> Create()
        {
            var model = new JobOfferCreateViewModel
            {
                AllSkills         = await SkillSelectListHelper.Get(),
                Employer          = await EmployerFacade.GetEmployerByEmail(User.Identity.Name),
                NumberOfQuestions = 1
            };

            return(View(model));
        }
        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> Delete(int id, FormCollection collection)
        {
            var currentEmployer = await EmployerFacade.GetEmployerByEmail(User.Identity.Name);

            try
            {
                await JobOfferFacade.DeleteJobOffer(id, currentEmployer);

                return(RedirectToAction("OffersOfCurrentEmployer"));
            }
            catch
            {
                return(View());
            }
        }
        public async Task <ActionResult> Edit(int id, JobOfferCreateViewModel model)
        {
            var currentEmployer = await EmployerFacade.GetEmployerByEmail(User.Identity.Name);

            if (ModelState.IsValid)
            {
                model.JobOfferCreateDto.EmployerId = currentEmployer.Id;
                await JobOfferFacade.EditJobOffer(model.JobOfferCreateDto, currentEmployer);

                return(RedirectToAction("OffersOfCurrentEmployer"));
            }

            model.AllSkills = await SkillSelectListHelper.Get();

            model.Employer = currentEmployer;
            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));
        }