Exemplo n.º 1
0
        private static async Task TestCreateApplicationUnRegistered(Mapper mapper)
        {
            JobApplicationFacade jobApplicationFacade = new JobApplicationFacade(Provider,
                                                                                 new JobApplicationService(mapper, new JobApplicationRepository(Provider),
                                                                                                           new JobApplicationQueryObject(mapper, new EntityFrameworkQuery <JobApplication>(Provider))));

            List <QuestionAnswerDto> questionAnswers = new List <QuestionAnswerDto>();

            questionAnswers.Add(new QuestionAnswerDto {
                QuestionId = 1, Text = "aaaaa"
            });
            await jobApplicationFacade.CreateApplication(new JobApplicationCreateDto()
            {
                Applicant = new ApplicantDto()
                {
                    Education   = "basic",
                    Email       = "*****@*****.**",
                    FirstName   = "Dilino",
                    LastName    = "Master",
                    PhoneNumber = "+444234956"
                },
                JobOfferId      = 1,
                QuestionAnswers = questionAnswers
            });

            var results = await jobApplicationFacade.GetAllApplications();

            foreach (var resultsItem in results)
            {
                Console.WriteLine(resultsItem.JobApplicationStatus);
            }
        }
Exemplo n.º 2
0
        private static async Task TestCreateApplicationRegistered(Mapper mapper)
        {
            JobApplicationFacade jobApplicationFacade = new JobApplicationFacade(Provider,
                                                                                 new JobApplicationService(mapper, new JobApplicationRepository(Provider),
                                                                                                           new JobApplicationQueryObject(mapper, new EntityFrameworkQuery <JobApplication>(Provider))));

            List <QuestionAnswerDto> questionAnswers = new List <QuestionAnswerDto>();

            questionAnswers.Add(new QuestionAnswerDto {
                QuestionId = 1, Text = "aaaaa"
            });
            await jobApplicationFacade.CreateApplication(new JobApplicationDto
            {
                ApplicantId     = 1,
                JobOfferId      = 1,
                QuestionAnswers = questionAnswers
            });

            var results = await jobApplicationFacade.GetAllApplications();

            foreach (var resultsItem in results)
            {
                Console.WriteLine(resultsItem.JobApplicationStatus);
            }
        }
        public async Task <ActionResult> ApplicationsOfCurrentUser()
        {
            var user = await UserFacade.GetUserByEmail(User.Identity.Name);

            var aplications = await JobApplicationFacade.GetByApplicant(user.Id);

            return(View("Index", aplications.Items));
        }
Exemplo n.º 4
0
 public JobApplicationController(JobOfferFacade jobOfferFacade, JobApplicationFacade jobApplicationFacade, UserFacade userFacade, JobSeekerFacade jobSeekerFacade, CompanyFacade companyFacade)
 {
     this.jobOfferFacade       = jobOfferFacade;
     this.jobApplicationFacade = jobApplicationFacade;
     this.userFacade           = userFacade;
     this.jobSeekerFacade      = jobSeekerFacade;
     this.companyFacade        = companyFacade;
 }
        public async Task <ActionResult> Delete(int id, FormCollection collection)
        {
            try
            {
                await JobApplicationFacade.DeleteApplication(id, await EmployerFacade.GetEmployerByEmail(User.Identity.Name));

                return(RedirectToAction("ApplicationsByJobOffer", new { id = (await JobApplicationFacade.GetApplication(id)).JobOffer.Id }));
            }
            catch
            {
                return(View());
            }
        }
        public async Task <ActionResult> Delete(int id)
        {
            var emoloyer = await EmployerFacade.GetEmployerByEmail(User.Identity.Name);

            var application = await JobApplicationFacade.GetApplication(id);

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

            return(View(application));
        }
        public async Task <ActionResult> AcceptApplicationAndCloseOther(int id)
        {
            ViewBag.Action = "Accept application and close all other";
            var emoloyer = await EmployerFacade.GetEmployerByEmail(User.Identity.Name);

            var application = await JobApplicationFacade.GetApplication(id);

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

            return(View("ChangeApplicationStatus", application));
        }
        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(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));
        }
Exemplo n.º 10
0
        public void JobApplicationFacadeTest()
        {
            var unit = new UnitOfWork(GetInMemoryOptions());

            Seeder.Seed(unit);

            var jobApplicationService = new JobApplicationService(unit, new JobApplicationQueryObject(unit));
            var jobApplicationFacade  = new JobApplicationFacade(unit, mapper,
                                                                 new JobApplicationService(unit, new JobApplicationQueryObject(unit)));

            var jason = unit.JobSeekerRepository.GetById(3);

            Assert.Equal("Jason", jason.Name);
            var application = jobApplicationService.GetByApplicantIdAsync(jason.Id ?? -1).Result.First();


            // Null ID get
            var excp1 = Assert.Throws <AggregateException>(() =>
                                                           jobApplicationFacade.GetByApplicantIdAsync(new JobApplicationDto()).Wait());

            Assert.Contains("ApplicantId can't be null!",
                            excp1.Message);

            excp1 = Assert.Throws <AggregateException>(() =>
                                                       jobApplicationFacade.GetByApplicantIdAndStatusAsync(new JobApplicationDto(), Status.Rejected).Wait());
            Assert.Contains("ApplicantId can't be null!",
                            excp1.Message);

            excp1 = Assert.Throws <AggregateException>(() =>
                                                       jobApplicationFacade.GetByJobOfferIdAsync(new JobApplicationDto()).Wait());
            Assert.Contains("JobOfferId can't be null!",
                            excp1.Message);

            excp1 = Assert.Throws <AggregateException>(() =>
                                                       jobApplicationFacade.GetByJobOfferIdAndStatusAsync(new JobApplicationDto(), Status.Rejected).Wait());
            Assert.Contains("JobOfferId can't be null!",
                            excp1.Message);

            // Null ID edit/update
            var excp2 = Assert.Throws <AggregateException>(() =>
                                                           jobApplicationFacade.UpdateStatusAsync(mapper
                                                                                                  .Map <JobApplicationDto>(new JobApplication()), Status.Rejected).Wait());

            Assert.Contains("JobApplicationId can't be null!",
                            excp2.Message);

            // Null ID delete
            excp2 = Assert.Throws <AggregateException>(() =>
                                                       jobApplicationFacade.DeleteAsync(mapper
                                                                                        .Map <JobApplicationDto>(new JobApplication())).Wait());
            Assert.Contains("JobApplicationId can't be null!",
                            excp2.Message);

            // Addition with conflicting ID
            // This invalidates the database
            var id1 = unit.JobApplicationRepository.GetById(1);

            Assert.NotNull(id1); // makes sure company with id 1 is already in database
            var excp = Assert.Throws <AggregateException>(() =>
                                                          jobApplicationFacade.ApplyToJobOfferAsync(new JobApplicationDto()
            {
                Id = 1
            }).Wait());

            Assert.Contains("The instance of entity type 'JobApplication' cannot be tracked " +
                            "because another instance with the same key value for {'Id'} is already being tracked.",
                            excp.Message);

            unit.Dispose();
        }
        public async Task <ActionResult> Details(int id)
        {
            var application = await JobApplicationFacade.GetApplication(id);

            return(View(application));
        }
        public async Task <ActionResult> AcceptApplicationAndCloseOther(int id, FormCollection collection)
        {
            await JobApplicationFacade.AcceptOnlyThisApplication(id, await EmployerFacade.GetEmployerByEmail(User.Identity.Name));

            return(RedirectToAction("ApplicationsByJobOffer", new { id = (await JobApplicationFacade.GetApplication(id)).JobOffer.Id }));
        }