public void Test_UpdateEmployer()
 {
     EmployerDAO employer4 = new EmployerDAO() { ID = 3, EmployerID = 3, Name = "UpdatedEmployer", EmployerAddress = "UpdatedAddress", PhoneNumber = "UpdatedPhone" };
     employerService.UpdateEmployer(employer4);
     Assert.AreEqual(employerService.GetEmployerByID(3).Name, "UpdatedEmployer");
     Assert.AreEqual(employerService.GetEmployerByID(3).PhoneNumber, "UpdatedPhone");
     Assert.AreEqual(employerService.GetEmployerByID(3).EmployerAddress, "UpdatedAddress");
 }
 private void initializeEmployer(EmployerDAO employer, int id, int employerID, string name, string employerAddress, string phoneNumber)
 {
     employer.ID = id;
     employer.EmployerID = employerID;
     employer.Name = name;
     employer.EmployerAddress = employerAddress;
     employer.PhoneNumber = phoneNumber;
 }
 public void Test_CreateEmployer()
 {
     EmployerDAO employer4 = new EmployerDAO() { ID = 4, EmployerID = 4, Name = "TestEmployer", EmployerAddress = "TestAddress", PhoneNumber = "TestPhone" };
     employerService.CreateEmployer(employer4);
     Assert.AreEqual(employerService.GetEmployerByID(4).EmployerID, 4);
     Assert.AreEqual(employerService.GetEmployerByID(4).ID, 4);
     Assert.AreEqual(employerService.GetEmployerByID(4).Name, "TestEmployer");
     Assert.AreEqual(employerService.GetEmployers().Count, 4);
 }
        internal void SetUp()
        {
            EmployerDAO employer1 = new EmployerDAO() { ID = 1, EmployerID = 1, Name = "Intel", EmployerAddress = "Address1", PhoneNumber = "503" };
            EmployerDAO employer2 = new EmployerDAO() { ID = 2, EmployerID = 2, Name = "Google", EmployerAddress = "Address2", PhoneNumber = "504" };
            EmployerDAO employer3 = new EmployerDAO() { ID = 3, EmployerID = 3, Name = "Microsoft", EmployerAddress = "Address3", PhoneNumber = "505" };

            Employers.Add(employer1);
            Employers.Add(employer2);
            Employers.Add(employer3);
        }
 public bool UpdateEmployer(EmployerDAO newEmp)
 {
     foreach (var e in Employers)
         if (e.EmployerID == newEmp.EmployerID)
         {
             Employers.Remove(e);
             Employers.Add(newEmp);
             return true;
         }
     return false;
 }
 public bool CreateEmployer(EmployerDAO e)
 {
     Employers.Add(e);
     return true;
 }
        public bool UpdateEmployer(EmployerDAO newEmp)
        {
            using (AESDatabaseDataContext db = new AESDatabaseDataContext())
            {
                Employer em = db.Employers.Single(emp => emp.Employer_ID == newEmp.EmployerID);

                em.Name = newEmp.Name;
                em.EmployerAddress = newEmp.EmployerAddress;
                em.PhoneNumber = newEmp.PhoneNumber;

                try
                {
                    db.SubmitChanges();
                }
                catch (Exception e)
                {
                    throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
                }
            }

            return true;
        }
        public bool CreateEmployer(EmployerDAO emp)
        {
            Employer employer = new Employer
            {
                Name = emp.Name,
                EmployerAddress = emp.EmployerAddress,
                PhoneNumber = emp.PhoneNumber
            };

            using (AESDatabaseDataContext db = new AESDatabaseDataContext())
            {
                db.Employers.InsertOnSubmit(employer);
                try
                {
                    db.SubmitChanges();
                }
                catch (Exception e)
                {
                    throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
                }
            }

            return true;
        }
        public IList<EmployerDAO> GetEmployers()
        {
            try
            {
                using (AESDatabaseDataContext db = new AESDatabaseDataContext())
                {
                    IList<Employer> emps = db.Employers.ToList();
                    List<EmployerDAO> result = new List<EmployerDAO>();
                    foreach (var employer in emps)
                    {
                        EmployerDAO temp = new EmployerDAO
                        {
                            EmployerID = employer.Employer_ID,
                            Name = employer.Name,
                            EmployerAddress = employer.EmployerAddress,
                            PhoneNumber = employer.PhoneNumber
                        };

                        result.Add(temp);
                    }

                    return (result != null ? result : null);
                }
            }
            catch (Exception e)
            {
                throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
            }
        }
 public EmployerDAO GetEmployerByID(int id)
 {
     try
     {
         using (AESDatabaseDataContext db = new AESDatabaseDataContext())
         {
             Employer employer = (from em in db.Employers where em.Employer_ID == id select em).FirstOrDefault();
             EmployerDAO result = new EmployerDAO
             {
                 EmployerID = employer.Employer_ID,
                 Name = employer.Name,
                 EmployerAddress = employer.EmployerAddress,
                 PhoneNumber = employer.PhoneNumber
             };
             return (result != null ? result : null);
         }
     }
     catch (Exception e)
     {
         throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
     }
 }