private void initializeJobOpening(JobOpeningDAO jobOpening, int id, int jobOpeningID, int jobID, int approved)
 {
     jobOpening.ID = id;
     jobOpening.JobOpeningID = jobOpeningID;
     jobOpening.JobID = jobID;
     jobOpening.Approved = approved;
 }
 public void Test_UpdateJobOpening()
 {
     JobOpeningDAO jobopening4 = new JobOpeningDAO() { JobOpeningID = 3, JobID = 4, Approved = 0 };
     jobOpeningService.UpdateJobOpening(jobopening4);
     Assert.AreEqual(jobOpeningService.GetJobOpeningByID(3).Approved, 0);
     Assert.AreEqual(jobOpeningService.GetJobOpenings().Count, 3);
 }
 public void Test_CreateJobOpening()
 {
     JobOpeningDAO jobopening4 = new JobOpeningDAO() { JobOpeningID = 4, JobID = 4, Approved = 1 };
     jobOpeningService.CreateJobOpening(jobopening4);
     Assert.IsNotNull(jobOpeningService.GetJobOpeningByID(4));
     Assert.AreEqual(jobOpeningService.GetJobOpenings().Count, 4);
 }
        internal void SetUp()
        {
            JobOpeningDAO jobopening1 = new JobOpeningDAO() { JobOpeningID = 1, JobID = 1, Approved = 1 };
            JobOpeningDAO jobopening2 = new JobOpeningDAO() { JobOpeningID = 2, JobID = 2, Approved = 1 };
            JobOpeningDAO jobopening3 = new JobOpeningDAO() { JobOpeningID = 3, JobID = 3, Approved = 1 };

            JobOpenings.Add(jobopening1);
            JobOpenings.Add(jobopening2);
            JobOpenings.Add(jobopening3);
        }
 public bool UpdateJobOpening(JobOpeningDAO newEmp)
 {
     foreach(var jo in JobOpenings)
         if(jo.JobOpeningID == newEmp.JobOpeningID)
         {
             JobOpenings.Remove(jo);
             JobOpenings.Add(newEmp);
             return true;
         }
     return false;
 }
 public bool CreateJobOpening(JobOpeningDAO e)
 {
     JobOpenings.Add(e);
     return true;
 }
        public bool CreateJobOpening(JobOpeningDAO jbOp)
        {
            JobOpening jobOpening = new JobOpening
            {
                JobOpening_ID = jbOp.JobOpeningID,
                OpenDate = (DateTime)jbOp.OpenDate,
                Job_ID = jbOp.JobID,
                Approved = (byte)jbOp.Approved,
                Description = jbOp.Description,
                Store_ID = jbOp.StoreID
            };

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

            return true;
        }
        public bool UpdateJobOpening(JobOpeningDAO newJbOp)
        {
            using (AESDatabaseDataContext db = new AESDatabaseDataContext())
            {
                JobOpening jobOpening = db.JobOpenings.Single(jbOp => jbOp.JobOpening_ID == newJbOp.JobOpeningID);

                if (newJbOp.JobOpeningID > 0)
                    jobOpening.JobOpening_ID = newJbOp.JobOpeningID;

                if (newJbOp.OpenDate != null)
                    jobOpening.OpenDate = (DateTime)newJbOp.OpenDate;

                if (newJbOp.JobID > 0)
                    jobOpening.Job_ID = newJbOp.JobID;

                if (newJbOp.Approved == 0 || newJbOp.Approved == 1)
                    jobOpening.Approved = (byte)newJbOp.Approved;

                jobOpening.Description = newJbOp.Description;

                if (newJbOp.StoreID > 0)
                    jobOpening.Store_ID = newJbOp.StoreID;

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

            return true;
        }
        public IList<JobOpeningDAO> GetJobOpenings()
        {
            try
            {
                using (AESDatabaseDataContext db = new AESDatabaseDataContext())
                {
                    //IList<JobOpening> jobOpenings = db.JobOpenings.ToList();
                    IList<JobOpening> jobOpenings = (from jobOpening in db.JobOpenings select jobOpening).OrderBy(o => o.JobOpening_ID).ToList();
                    List<JobOpeningDAO> result = new List<JobOpeningDAO>();

                    foreach (var jobOpening in jobOpenings)
                    {
                        JobOpeningDAO temp = new JobOpeningDAO
                        {
                            ID = jobOpening.JobOpening_ID,
                            JobOpeningID = jobOpening.JobOpening_ID,
                            OpenDate = jobOpening.OpenDate,
                            JobID = jobOpening.Job_ID,
                            Approved = (byte)jobOpening.Approved,
                            Description = jobOpening.Description,
                            StoreID = jobOpening.Store_ID
                        };

                        result.Add(temp);
                    }

                    return (result != null ? result : null);
                }
            }
            catch (Exception e)
            {
                throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
            }
        }
 public JobOpeningDAO GetJobOpeningByID(int id)
 {
     try
     {
         using (AESDatabaseDataContext db = new AESDatabaseDataContext())
         {
             JobOpening jobOpening = (from jbOp in db.JobOpenings where jbOp.JobOpening_ID == id select jbOp).FirstOrDefault();
             JobOpeningDAO result = new JobOpeningDAO
             {
                 ID = jobOpening.JobOpening_ID,
                 JobOpeningID = jobOpening.JobOpening_ID,
                 OpenDate = jobOpening.OpenDate,
                 JobID = jobOpening.Job_ID,
                 Approved = (byte)jobOpening.Approved,
                 Description = jobOpening.Description,
                 StoreID = jobOpening.Store_ID
             };
             return (result != null ? result : null);
         }
     }
     catch (Exception e)
     {
         throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
     }
 }