Ejemplo n.º 1
0
        public ActionResult Apply(JOB_APPLICATION apply)
        {
            JobApplicationService service = new JobApplicationService();

            if (service.Create(apply))
            {
                return(RedirectToAction("Index", "Home"));
            }
            return(View());
        }
Ejemplo n.º 2
0
        public void JobApplicationServiceTests()
        {
            // Addition
            var unit = new UnitOfWork(GetInMemoryOptions());
            var jobApplicationService = new JobApplicationService(unit, new JobApplicationQueryObject(unit));
            var c1 = new JobApplication()
            {
                Text   = "Lol",
                Status = Status.Unresolved
            };

            Assert.Null(c1.Id);
            jobApplicationService.Create(c1);
            unit.SaveChanges();
            Assert.NotEqual(-1, c1.Id);
            Assert.Equal("Lol", unit.JobApplicationRepository.GetById(c1.Id ?? -1).Text);

            Seeder.Seed(unit);

            var c2 = new JobApplication()
            {
                Text = "New addition"
            };

            Assert.Null(c2.Id);
            jobApplicationService.Create(c2);
            unit.SaveChanges();
            Assert.NotEqual(-1, c2.Id);
            Assert.Equal("New addition", unit.JobApplicationRepository.GetById(c2.Id ?? -1).Text);

            // UpdateStaus
            Assert.Equal(Status.Unresolved, unit.JobApplicationRepository.GetById(c1.Id ?? -1).Status);
            jobApplicationService.UpdateStatus(c1.Id ?? -1, Status.Accepted);
            unit.SaveChanges();
            Assert.Equal(Status.Accepted, unit.JobApplicationRepository.GetById(c1.Id ?? -1).Status);

            // Delete
            int size = unit.JobApplicationRepository.GetAll().Count();

            jobApplicationService.Delete(c1.Id ?? -1);
            unit.SaveChanges();
            Assert.Equal(size - 1, unit.JobApplicationRepository.GetAll().Count());
        }
        public async void GivenCreateNewJobApplication_WhenCreatingNewJobApplication_ThenNewJobApplicationIsCreated()
        {
            var testJobApp = new JobApplication(Guid.NewGuid(), Guid.NewGuid());
            //Given
            var mockRepo     = Substitute.For <JobApplicationRepository>();
            var mockRepoFile = Substitute.For <FileRepository>();

            mockRepo.Create(testJobApp)
            .Returns(Task.FromResult(testJobApp));
            var mockLogger             = Substitute.For <ILoggerManager>();
            var _jobApplcaitionService = new JobApplicationService(mockRepo, mockRepoFile, mockLogger);
            //When
            var createdJobapp = await _jobApplcaitionService.Create(testJobApp);


            //Then
            Assert.Equal(createdJobapp, testJobApp);
        }
Ejemplo n.º 4
0
 public async Task ApplyToJobOfferAsync(JobApplicationDto jobApplicationDto)
 {
     jobApplicationService.Create(mapper.Map <JobApplication>(jobApplicationDto));
     await unitOfWork.SaveChangesAsync();
 }