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(); } }
private void button1_Click(object sender, EventArgs e) { var user = JobSeekerService.GetById(LoggedData.LoggedJobSeeker.Id); // var offer = JobOfferService.GetOffersByBusinessName(lblBusinessName.Text); // var thisApplication = new Application_(offerGlobal, user); var application = ApplicationService.GetApplicationById(offerGlobal.Id); if (btnJobApply.BackColor == Color.DarkSlateGray) { // thisApplication.Status = "Applied"; ApplicationService.Apply(offerGlobal, user, "Applied"); MessageBox.Show("You applied succesfully"); btnJobApply.BackColor = Color.WhiteSmoke; btnJobApply.ForeColor = Color.Black; btnJobApply.Text = "Undo Application"; } else if (btnJobApply.BackColor == Color.WhiteSmoke) { // thisApplication.Status = "Neutral"; // MessageBox.Show(ApplicationService.GetLastApplication().ToString()); btnJobApply.BackColor = Color.DarkSlateGray; btnJobApply.ForeColor = Color.White; btnJobApply.Text = "Apply"; ApplicationService.GetLastApplication().Status = "Neutral"; ApplicationService.GetApplicationById(offerGlobal.Id); var last = ApplicationService.GetLastApplication(); ApplicationService.DeleteApplication(last.Id); } }
private void btnLogin_Click(object sender, EventArgs e) { // LoggedData.LoggedJobSeeker = null; bool Exists = JobSeekerService.DoesThisNameExist(txtUsername.Text); if (Exists) { //MessageBox.Show("Go to joobSeker web"); //Initialzing object var user = JobSeekerService.GetByUsername(txtUsername.Text); LoggedData.LoggedJobSeeker.Username = txtUsername.Text; LoggedData.LoggedJobSeeker.Name = user.Name; LoggedData.LoggedJobSeeker.Password = user.Password; LoggedData.LoggedJobSeeker.LastName = user.LastName; LoggedData.LoggedJobSeeker.Id = user.Id; this.Close(); HomeJobSeeker h = new HomeJobSeeker(); h.Show(); } else if (BusinessService.DoesThisNameExist(txtUsername.Text)) { LoggedData.LoggedBusiness.Username = txtUsername.Text; Home h1 = new Home(); h1.Show(); } }
public async Task GetJobSeekerForUser_WithNonExistentUser_ReturnsNull() { var testUserName = Guid.NewGuid().ToString(); var context = new JobFinderDbContext(new DbContextOptionsBuilder <JobFinderDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options); var model = new JobSeeker { FirstName = "TestFirstName", LastName = "TestLastName", User = new User { UserName = testUserName } }; var jobSeekerService = new JobSeekerService(new EfRepository <User>(context), new EfRepository <JobSeeker>(context)); var result = await jobSeekerService.GetJobSeeker(testUserName); Assert.Null(result); }
public Form1() { InitializeComponent(); JobSeekerService.RegisterJobSeeker(new JobSeeker("LEONIT", "kULETA", null, "123456", 46, "Leonit", "MALE")); MessageBox.Show(JobSeekerService.DoesThisNameExist("LEONIT").ToString()); }
public async Task CreateAsync_WithInvalidModel_ReturnsFalse() { var context = new JobFinderDbContext(new DbContextOptionsBuilder <JobFinderDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options); var user = new User { UserName = "******" }; await context.Users.AddAsync(user); context.SaveChanges(); var serviceModel = new JobSeekerServiceModel { User = new UserServiceModel { UserName = user.UserName } }; var jobSeekerService = new JobSeekerService(new EfRepository <User>(context), new EfRepository <JobSeeker>(context)); var result = await jobSeekerService.CreateAsync(serviceModel); Assert.False(result); var dbModel = await context.JobSeekers.AnyAsync(); Assert.False(dbModel); }
public async Task GetAllJobSeekers_WithData_WorksCorrectly() { var context = new JobFinderDbContext(new DbContextOptionsBuilder <JobFinderDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options); var expectedResults = new[] { "JobSeeker1", "JobSeeker2", "JobSeeker3" } .OrderBy(j => j) .ToArray(); foreach (var model in expectedResults) { context.JobSeekers.Add(new JobSeeker() { FirstName = model, LastName = model, User = new User { UserName = model } }); } await context.SaveChangesAsync(); var jobSeekerService = new JobSeekerService(new EfRepository <User>(context), new EfRepository <JobSeeker>(context)); var actualResults = (await jobSeekerService.GetAllJobSeekers()) .Select(j => j.FirstName) .OrderBy(j => j) .ToArray(); Assert.Equal(expectedResults, actualResults); }
public async Task GetJobSeekerForUser_WithValidUser_WorksCorrectly() { string userName = "******"; var context = new JobFinderDbContext(new DbContextOptionsBuilder <JobFinderDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options); var model = new JobSeeker { FirstName = "TestFirstName", LastName = "TestLastName", User = new User { UserName = userName } }; await context.JobSeekers.AddAsync(model); context.SaveChanges(); var jobSeekerService = new JobSeekerService(new EfRepository <User>(context), new EfRepository <JobSeeker>(context)); var serviceModel = await jobSeekerService.GetJobSeeker(userName); var dbModel = await context.JobSeekers.SingleOrDefaultAsync(); Assert.Equal(dbModel.Id, serviceModel.Id); }
public async Task GetAsync_WithNotExistingJobSeeker_ReturnsFalse() { string userName = "******"; var context = new JobFinderDbContext(new DbContextOptionsBuilder <JobFinderDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options); var model = new JobSeeker { FirstName = "TestFirstName", LastName = "TestLastName", User = new User { UserName = userName } }; var jobSeekerService = new JobSeekerService(new EfRepository <User>(context), new EfRepository <JobSeeker>(context)); var result = await jobSeekerService.GetJobSeekerById(model.Id); Assert.Null(result); }
public async Task UpdateAsync_WithNonExistentJobSeeker_ReturnsFalse() { var context = new JobFinderDbContext(new DbContextOptionsBuilder <JobFinderDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options); var model = new JobSeeker { FirstName = "TestFirstName", LastName = "TestLastName", User = new User { UserName = "******" } }; var serviceModel = new JobSeekerServiceModel { Id = model.Id }; var jobSeekerService = new JobSeekerService(new EfRepository <User>(context), new EfRepository <JobSeeker>(context)); var result = await jobSeekerService.UpdateAsync(serviceModel); Assert.False(result); }
public JobSeekerFacade(UnitOfWork unitOfWork, IMapper mapper, JobSeekerService jobSeekerService, UserService userService) { this.unitOfWork = unitOfWork; this.mapper = mapper; this.jobSeekerService = jobSeekerService; this.userService = userService; }
public Statistic() { InitializeComponent(); lblBusinessNum.Text = BusinessService.GetBusinessNum().ToString(); lbJobSeekerNum.Text = JobSeekerService.GetJobSeekerNum().ToString(); lblOfferNum.Text = JobOfferService.GetOfferNum().ToString(); }
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); }
public static IJobSeekerService<JobSeeker> GetJobSeeker() { IJobSeekerService<JobSeeker> serviceObj = null; switch (sectionHandler.ConnectionStringName) { case DataBaseType.SKILLSMART_MONGO_DB: serviceObj = new JobSeekerService(DatabaseFactory.CreateMongoDatabase()); break; default: serviceObj = new JobSeekerService(DatabaseFactory.CreateMongoDatabase()); break; } return serviceObj; }
public async Task GetAllJobSeekers_WithNoData_ReturnsNull() { var context = new JobFinderDbContext(new DbContextOptionsBuilder <JobFinderDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options); var jobSeekerService = new JobSeekerService(new EfRepository <User>(context), new EfRepository <JobSeeker>(context)); var actualResults = await jobSeekerService.GetAllJobSeekers(); Assert.Empty(actualResults); }
public void JobSeekerFacadeTest() { var unit = new UnitOfWork(GetInMemoryOptions()); Seeder.Seed(unit); var userService = new UserService(unit, new UserQueryObject(unit)); var jobSeekerService = new JobSeekerService(unit); var jobSeekerFacade = new JobSeekerFacade(unit, mapper, jobSeekerService, userService); var s = new JobSeekerDto() { Name = "Lol" }; jobSeekerFacade.RegisterAsync(s).Wait(); Assert.NotNull(s.Id); Assert.NotNull(jobSeekerService.GetJobSeeker(s.Id ?? -1).Result); s.Id = null; s.Name = "new lol"; // Null ID get var excp1 = Assert.Throws <AggregateException>(() => jobSeekerFacade.GetInfoAsync(s).Wait()); Assert.Contains("JobSeekerDto.Id can't be null!", excp1.Message); // Null ID edit/update var excp2 = Assert.Throws <AggregateException>(() => jobSeekerFacade.EditInfoAsync(mapper.Map <JobSeekerDto>(s)).Wait()); Assert.Contains("Attempted to update or delete an entity that does not exist in the store.", excp2.Message); // Addition with conflicting ID // This invalidates the database var id1 = unit.JobSeekerRepository.GetById(1); Assert.NotNull(id1); // makes sure company with id 1 is already in database var excp = Assert.Throws <AggregateException>(() => jobSeekerFacade.RegisterAsync(new JobSeekerDto() { Id = 1 }).Wait()); Assert.Contains("The instance of entity type 'JobSeeker' cannot be tracked " + "because another instance with the same key value for {'Id'} is already being tracked.", excp.Message); unit.Dispose(); }
public static IJobSeekerService <JobSeeker> GetJobSeeker() { IJobSeekerService <JobSeeker> serviceObj = null; switch (sectionHandler.ConnectionStringName) { case DataBaseType.SKILLSMART_MONGO_DB: serviceObj = new JobSeekerService(DatabaseFactory.CreateMongoDatabase()); break; default: serviceObj = new JobSeekerService(DatabaseFactory.CreateMongoDatabase()); break; } return(serviceObj); }
public async Task UpdateAsync_WithValidModel_WorksCorrectly() { const string expectedResult = "TestName12345"; var context = new JobFinderDbContext(new DbContextOptionsBuilder <JobFinderDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options); var model = new JobSeeker { FirstName = "TestFirstName", LastName = "TestLastName", User = new User { UserName = "******" } }; await context.JobSeekers.AddAsync(model); context.SaveChanges(); var companyService = new CompanyService(new EfRepository <User>(context), new EfRepository <Company>(context)); var serviceModel = new JobSeekerServiceModel { Id = model.Id, FirstName = expectedResult, LastName = expectedResult }; var jobSeekerService = new JobSeekerService(new EfRepository <User>(context), new EfRepository <JobSeeker>(context)); var result = await jobSeekerService.UpdateAsync(serviceModel); Assert.True(result); var actualResultFirstName = (await context.JobSeekers.SingleAsync(j => j.Id == model.Id)).FirstName; var actualResultLastName = (await context.JobSeekers.SingleAsync(j => j.Id == model.Id)).LastName; Assert.Equal(expectedResult, actualResultFirstName); Assert.Equal(expectedResult, actualResultLastName); }
public async Task CreateAsync_WithValidModel_WorksCorrectly() { var context = new JobFinderDbContext(new DbContextOptionsBuilder <JobFinderDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options); var user = new User { UserName = "******" }; await context.Users.AddAsync(user); context.SaveChanges(); var serviceModel = new JobSeekerServiceModel { FirstName = "TestFirstName", LastName = "TestLastName", User = new UserServiceModel { UserName = user.UserName } }; var jobSeekerService = new JobSeekerService(new EfRepository <User>(context), new EfRepository <JobSeeker>(context)); var result = await jobSeekerService.CreateAsync(serviceModel); Assert.True(result); var dbModel = context.JobSeekers.SingleOrDefault(); Assert.NotNull(dbModel); Assert.Equal(user.Id, dbModel.UserId); }
public async Task CreateAsync_WithNonExistentUser_ReturnsFalse() { var context = new JobFinderDbContext(new DbContextOptionsBuilder <JobFinderDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options); var serviceModel = new JobSeekerServiceModel { FirstName = "TestFirstName", LastName = "TestLastName" }; var jobSeekerService = new JobSeekerService(new EfRepository <User>(context), new EfRepository <JobSeeker>(context)); var result = await jobSeekerService.CreateAsync(serviceModel); Assert.False(result); var dbModel = await context.JobSeekers.AnyAsync(); Assert.False(dbModel); }
private void btnRegisterBusiness_Click(object sender, EventArgs e) { if (BusinessService.DoesThisNameExist(txtBusinessName.Text) || JobSeekerService.DoesThisNameExist(txtBusinessName.Text)) { MessageBox.Show("This Name is already taken.", "Warning"); } else { var business = new Business(new BusinessType(cmbCategory.SelectedItem.ToString()), new Category(cmbTypeBusiness.SelectedItem.ToString()), txtBusinessName.Text, txtUsername.Text, txtBusinessPassword.Text); LoggedData.LoggedBusiness = business; BusinessService.RegisterBusiness(business); Home h1 = new Home(); // MessageBox.Show(LoggedData.LoggedBusiness.Name); // this.Close(); h1.Show(); } }