Exemple #1
0
        public void JobSeekerServiceTests()
        {
            // Addition
            var unit             = new UnitOfWork(GetInMemoryOptions());
            var jobSeekerService = new JobSeekerService(unit);
            var s1 = new JobSeeker()
            {
                Name    = "Joey",
                Surname = "Tribbiani"
            };

            Assert.Null(s1.Id);
            jobSeekerService.RegisterJobSeeker(s1);
            unit.SaveChanges();
            Assert.NotEqual(-1, s1.Id);
            Assert.Equal("Joey", unit.JobSeekerRepository.GetById(s1.Id ?? -1).Name);

            Seeder.Seed(unit);

            var s2 = new JobSeeker()
            {
                Name = "Chandler"
            };

            Assert.Null(s2.Id);
            jobSeekerService.RegisterJobSeeker(s2);
            unit.SaveChanges();
            Assert.NotEqual(-1, s2.Id);
            Assert.Equal("Chandler", unit.JobSeekerRepository.GetById(s2.Id ?? -1).Name);


            // Getter
            Assert.Equal(unit.JobSeekerRepository.GetById(1).Name, jobSeekerService.GetJobSeeker(1).Result.Name);
            Assert.Equal(unit.JobSeekerRepository.GetById(3).Name, jobSeekerService.GetJobSeeker(3).Result.Name);
            Assert.Equal(unit.JobSeekerRepository.GetById(2).Name, jobSeekerService.GetJobSeeker(2).Result.Name);
            Assert.Equal(unit.JobSeekerRepository.GetById(2).Surname, jobSeekerService.GetJobSeeker(2).Result.Surname);
            Assert.Equal(unit.JobSeekerRepository.GetById(2).Email, jobSeekerService.GetJobSeeker(2).Result.Email);


            // Update
            s1.Name = "Rachel";
            jobSeekerService.UpdateJobSeeker(s1);
            unit.SaveChanges();
            Assert.Equal("Rachel", unit.JobSeekerRepository.GetById(s1.Id ?? -1).Name);
            Assert.Equal("Tribbiani", unit.JobSeekerRepository.GetById(s1.Id ?? -1).Surname);

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

            Assert.NotNull(seeker);
            var seekerName    = seeker.Name;
            var seekerSurname = seeker.Surname;

            seeker.Name = "Ross";
            jobSeekerService.UpdateJobSeeker(seeker);
            unit.SaveChanges();
            Assert.Equal("Ross", unit.JobSeekerRepository.GetById(seeker.Id ?? -1).Name);
            Assert.Equal(seekerSurname, unit.JobSeekerRepository.GetById(seeker.Id ?? -1).Surname);
        }
Exemple #2
0
        public Form1()
        {
            InitializeComponent();
            JobSeekerService.RegisterJobSeeker(new JobSeeker("LEONIT", "kULETA", null, "123456", 46, "Leonit", "MALE"));

            MessageBox.Show(JobSeekerService.DoesThisNameExist("LEONIT").ToString());
        }
Exemple #3
0
        private void btnRegisterJobSeeker_Click(object sender, EventArgs e)
        {
            if (JobSeekerService.DoesThisNameExist(txtFirstName.Text) || BusinessService.DoesThisNameExist(txtFirstName.Text))
            {
                MessageBox.Show("This Name is already taken.", "Warning");
            }
            else
            {
                string gender = "asd";
                if (rdbMale.Checked)
                {
                    gender = "Male";
                }
                else
                {
                    gender = "Female";
                }
                var jobSeeker = new JobSeeker(gender, txtLastName.Text, cmbCities.SelectedItem.ToString(), txtFirstName.Text, Convert.ToInt32(txtAge.Text), txtUserName.Text, txtPasswordJobSeeker.Text);
                JobSeekerService.RegisterJobSeeker(jobSeeker);
                LoggedData.LoggedJobSeeker = jobSeeker;

                HomeJobSeeker h1 = new HomeJobSeeker();
                //     this.Close();
                h1.Show();
            }
        }
        public async Task RegisterAsync(JobSeekerDto jobSeekerDto)
        {
            var jobSeeker = mapper.Map <JobSeeker>(jobSeekerDto);

            jobSeekerService.RegisterJobSeeker(jobSeeker);
            await unitOfWork.SaveChangesAsync();

            var user = await userService.GetByIdAsync(jobSeeker.UserId.Value);

            user.JobSeekerId = jobSeeker.Id;
            await unitOfWork.SaveChangesAsync();

            jobSeekerDto.Id = jobSeeker.Id; // this helps with unit tests
        }