internal void SetUp() { EmploymentDAO employment1 = new EmploymentDAO() { ID = 1, EmploymentID = 1, ApplicantID = 1, EmployerID = 1, Supervisor = "John Smith", Position = "Office", StartingSalary = "13.00", EndingSalary = "19.00", Responsibilities = "Making Coffee" }; EmploymentDAO employment2 = new EmploymentDAO() { ID = 2, EmploymentID = 2, ApplicantID = 2, EmployerID = 2, Supervisor = "Amanda Raw", Position = "Saleman", StartingSalary = "15.00", EndingSalary = "25.00", Responsibilities = "Sell Car" }; EmploymentDAO employment3 = new EmploymentDAO() { ID = 3, EmploymentID = 3, ApplicantID = 3, EmployerID = 3, Supervisor = "Anna Smith", Position = "Manager", StartingSalary = "25.00", EndingSalary = "30.00", Responsibilities = "General" }; Employments.Add(employment1); Employments.Add(employment2); Employments.Add(employment3); }
public bool UpdateEmployment(EmploymentDAO newEmp) { foreach(var e in Employments) if(e.EmploymentID == newEmp.EmploymentID) { Employments.Remove(e); Employments.Add(newEmp); return true; } return false; }
private void initializeEmployment(EmploymentDAO employment, int id, int employmentID, int applicantID, int employerID, string superviser, string position, string startingSalary, string endingSalary, string leavingReason, string responsibility ) { employment.ID = id; employment.EmploymentID = employmentID; employment.ApplicantID = applicantID; employment.EmployerID = employerID; employment.Supervisor = superviser; employment.Position = position; employment.StartingSalary = startingSalary; employment.EndingSalary = endingSalary; employment.ReasonForLeaving = leavingReason; employment.Responsibilities = responsibility; }
public bool CreateEmployment(EmploymentDAO e) { Employments.Add(e); return true; }
public bool CreateEmployment(EmploymentDAO emp) { Employment employment = new Employment { Applicant_ID = emp.ApplicantID, Employer_ID = emp.EmployerID, MayWeContactCurrentEmployer = emp.MayWeContactCurrentEmployer, EmployedFrom = emp.EmployedFrom, EmployedTo = emp.EmployedTo, Supervisor = emp.Supervisor, Position = emp.Position, StartingSalary = emp.StartingSalary, EndingSalary = emp.EndingSalary, ReasonForLeaving = emp.ReasonForLeaving, Responsibilities = emp.Responsibilities }; using (AESDatabaseDataContext db = new AESDatabaseDataContext()) { db.Employments.InsertOnSubmit(employment); try { db.SubmitChanges(); } catch (Exception e) { throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message)); } } return true; }
public bool UpdateEmployment(EmploymentDAO newEmp) { using (AESDatabaseDataContext db = new AESDatabaseDataContext()) { Employment em = db.Employments.Single(emp => emp.Employment_ID == newEmp.EmploymentID); em.Applicant_ID = newEmp.ApplicantID; em.Employer_ID = newEmp.EmployerID; em.MayWeContactCurrentEmployer = newEmp.MayWeContactCurrentEmployer; em.EmployedFrom = newEmp.EmployedFrom; em.EmployedTo = newEmp.EmployedTo; em.Supervisor = newEmp.Supervisor; em.Position = newEmp.Position; em.StartingSalary = newEmp.StartingSalary; em.EndingSalary = newEmp.EndingSalary; em.ReasonForLeaving = newEmp.ReasonForLeaving; em.Responsibilities = newEmp.Responsibilities; try { db.SubmitChanges(); } catch (Exception e) { throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message)); } } return true; }
public IList<EmploymentDAO> GetEmploymentsByName(string first, string last, string ssn) { try { using (AESDatabaseDataContext db = new AESDatabaseDataContext()) { Applicant applicant = (from a in db.Applicants where a.SSN == ssn && a.FirstName == first && a.LastName == last select a).FirstOrDefault(); IList<Employment> employments = (from e in db.Employments where e.Applicant_ID == applicant.Applicant_ID select e).ToList(); List<EmploymentDAO> result = new List<EmploymentDAO>(); foreach (var e in employments) { EmploymentDAO emp = new EmploymentDAO { ID = e.Employment_ID, EmploymentID = e.Employment_ID, ApplicantID = e.Applicant_ID, EmployerID = e.Employer_ID, MayWeContactCurrentEmployer = e.MayWeContactCurrentEmployer, EmployedFrom = e.EmployedFrom, EmployedTo = e.EmployedTo, Supervisor = e.Supervisor, Position = e.Position, StartingSalary = e.StartingSalary, EndingSalary = e.EndingSalary, ReasonForLeaving = e.ReasonForLeaving, Responsibilities = e.Responsibilities }; result.Add(emp); } return result; } } catch (Exception e) { throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message)); } }
public IList<EmploymentDAO> GetEmployments() { try { using (AESDatabaseDataContext db = new AESDatabaseDataContext()) { IList<Employment> emps = db.Employments.ToList(); List<EmploymentDAO> result = new List<EmploymentDAO>(); foreach (var employment in emps) { EmploymentDAO temp = new EmploymentDAO { EmploymentID = employment.Employment_ID, ApplicantID = employment.Applicant_ID, EmployerID = employment.Employer_ID, MayWeContactCurrentEmployer = employment.MayWeContactCurrentEmployer, EmployedFrom = employment.EmployedFrom, EmployedTo = employment.EmployedTo, Supervisor = employment.Supervisor, Position = employment.Position, StartingSalary = employment.StartingSalary, EndingSalary = employment.EndingSalary, ReasonForLeaving = employment.ReasonForLeaving, Responsibilities = employment.Responsibilities }; result.Add(temp); } return (result != null ? result : null); } } catch (Exception e) { throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message)); } }
public EmploymentDAO GetEmploymentByID(int id) { try { using (AESDatabaseDataContext db = new AESDatabaseDataContext()) { Employment employment = (from em in db.Employments where em.Employment_ID == id select em).FirstOrDefault(); EmploymentDAO result = new EmploymentDAO { EmploymentID = employment.Employment_ID, ApplicantID = employment.Applicant_ID, EmployerID = employment.Employer_ID, MayWeContactCurrentEmployer = employment.MayWeContactCurrentEmployer, EmployedFrom = employment.EmployedFrom, EmployedTo = employment.EmployedTo, Supervisor = employment.Supervisor, Position = employment.Position, StartingSalary = employment.StartingSalary, EndingSalary = employment.EndingSalary, ReasonForLeaving = employment.ReasonForLeaving, Responsibilities = employment.Responsibilities }; return (result != null ? result : null); } } catch (Exception e) { throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message)); } }
public void Test_UpdateEmployment() { EmploymentDAO employment3 = new EmploymentDAO() { ID = 3, EmploymentID = 3, ApplicantID = 4, EmployerID = 3, Supervisor = "Anna Smith", Position = "TestPosition", StartingSalary = "25.00", EndingSalary = "35.00", Responsibilities = "General" }; employmentService.UpdateEmployment(employment3); Assert.AreEqual(employmentService.GetEmploymentByID(3).Position, "TestPosition"); }
public void Test_CreateEmployment() { EmploymentDAO employment4 = new EmploymentDAO() { ID = 4, EmploymentID = 4, ApplicantID = 4, EmployerID = 3, Supervisor = "Anna Smith", Position = "Manager", StartingSalary = "25.00", EndingSalary = "35.00", Responsibilities = "General" }; employmentService.CreateEmployment(employment4); Assert.AreEqual(employmentService.GetEmployments().Count, 4); }