示例#1
0
 public void Test_UpdateJob()
 {
     JobDAO job5 = new JobDAO() { ID = 3, JobID = 3, Title = "TestTitle" };
     jobService.UpdateJob(job5);
     Assert.AreEqual(jobService.GetJobByID(3).Title, "TestTitle");
     Assert.AreEqual(jobService.GetJobByID(3).ID, 3);
     Assert.AreEqual(jobService.GetJobs().Count, 3);
 }
示例#2
0
 public void Test_CreateJob()
 {
     JobDAO job4 = new JobDAO() { ID = 4, JobID = 4, Title = "TestJob" };
     jobService.CreateJob(job4);
     Assert.AreEqual(jobService.GetJobByID(4).ID, 4);
     Assert.AreEqual(jobService.GetJobByID(4).JobID, 4);
     Assert.AreEqual(jobService.GetJobByID(4).Title, "TestJob");
     Assert.AreEqual(jobService.GetJobs().Count, 4);
 }
示例#3
0
        internal void SetUp()
        {
            JobDAO job1 = new JobDAO() { ID = 1, JobID = 1, Title = "Title1" };
            JobDAO job2 = new JobDAO() { ID = 2, JobID = 2, Title = "Title2" };
            JobDAO job3 = new JobDAO() { ID = 3, JobID = 3, Title = "Title3" };

            Jobs.Add(job1);
            Jobs.Add(job2);
            Jobs.Add(job3);
        }
示例#4
0
 public bool UpdateJob(JobDAO newEmp)
 {
     foreach(var j in Jobs)
         if(j.JobID == newEmp.JobID)
         {
             Jobs.Remove(j);
             Jobs.Add(newEmp);
             return true;
         }
     return false;
 }
        public bool UpdateJob(JobDAO newJb)
        {
            using (AESDatabaseDataContext db = new AESDatabaseDataContext())
            {
                Job job = db.Jobs.Single(jb => jb.Job_ID == newJb.JobID);
                job.Title = newJb.Title;

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

            return true;
        }
        public bool CreateJob(JobDAO jb)
        {
            Job job = new Job
            {
                Title = jb.Title,
            };

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

            return true;
        }
        public IList<JobDAO> GetJobs()
        {
            try
            {
                using (AESDatabaseDataContext db = new AESDatabaseDataContext())
                {
                    IList<Job> jobs = db.Jobs.ToList();
                    List<JobDAO> result = new List<JobDAO>();

                    foreach (var job in jobs)
                    {
                        JobDAO temp = new JobDAO
                        {
                            ID = job.Job_ID,
                            JobID = job.Job_ID,
                            Title = job.Title
                        };

                        result.Add(temp);
                    }

                    return (result != null ? result : null);
                }
            }
            catch (Exception e)
            {
                throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
            }
        }
 public JobDAO GetJobByID(int id)
 {
     try
     {
         using (AESDatabaseDataContext db = new AESDatabaseDataContext())
         {
             Job job = (from jb in db.Jobs where jb.Job_ID == id select jb).FirstOrDefault();
             JobDAO result = new JobDAO
             {
                 ID = job.Job_ID,
                 JobID = job.Job_ID,
                 Title = job.Title
             };
             return (result != null ? result : null);
         }
     }
     catch (Exception e)
     {
         throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
     }
 }
示例#9
0
 private void initializeJob(JobDAO job, int id, int jobID, string title)
 {
     job.ID = id;
     job.JobID = jobID;
     job.Title = title;
 }
示例#10
0
 public bool CreateJob(JobDAO e)
 {
     Jobs.Add(e);
     return true;
 }