예제 #1
0
 public void Test_UpdateSchool()
 {
     SchoolDAO school3 = new SchoolDAO() { ID = 3, SchoolID = 3, SchoolName = "TestName", SchoolAddress = "TestAddress" };
     schoolService.UpdateSchool(school3);
     Assert.AreEqual(schoolService.GetSchoolByID(3).SchoolName, "TestName");
     Assert.AreEqual(schoolService.GetSchoolByID(3).SchoolAddress, "TestAddress");
 }
예제 #2
0
 private void initializeSchool(SchoolDAO school, int id, int schoolID, string schoolName, string schoolAddress)
 {
     school.ID = id;
     school.SchoolID = schoolID;
     school.SchoolName = schoolName;
     school.SchoolAddress = schoolAddress;
 }
예제 #3
0
 public void Test_CreateSchool()
 {
     SchoolDAO school4 = new SchoolDAO() { ID = 4, SchoolID = 4, SchoolName = "Name4", SchoolAddress = "Address4" };
     schoolService.CreateSchool(school4);
     Assert.AreEqual(schoolService.GetSchools().Count, 4);
     Assert.AreEqual(schoolService.GetSchoolByID(4).SchoolAddress, "Address4");
 }
예제 #4
0
        internal void SetUp()
        {
            SchoolDAO school1 = new SchoolDAO() { ID = 1, SchoolID = 1, SchoolName = "Name1", SchoolAddress = "Address1" };
            SchoolDAO school2 = new SchoolDAO() { ID = 2, SchoolID = 2, SchoolName = "Name2", SchoolAddress = "Address2" };
            SchoolDAO school3 = new SchoolDAO() { ID = 3, SchoolID = 3, SchoolName = "Name3", SchoolAddress = "Address3" };

            Schools.Add(school1);
            Schools.Add(school2);
            Schools.Add(school3);
        }
예제 #5
0
 public bool UpdateSchool(SchoolDAO newEmp)
 {
     foreach(var s in Schools)
         if(s.SchoolID == newEmp.SchoolID)
         {
             Schools.Remove(s);
             Schools.Add(newEmp);
             return true;
         }
     return false;
 }
        public bool CreateSchool(SchoolDAO sch)
        {
            School school = new School
            {
                School_Name = sch.SchoolName,
                School_Address = sch.SchoolAddress
            };

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

            return true;
        }
        public bool UpdateSchool(SchoolDAO newSch)
        {
            using (AESDatabaseDataContext db = new AESDatabaseDataContext())
            {
                School school = db.Schools.Single(sch => sch.School_ID == newSch.SchoolID);

                school.School_Name = newSch.SchoolName;
                school.School_Address = newSch.SchoolAddress;

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

            return true;
        }
        public IList<SchoolDAO> GetSchools()
        {
            try
            {
                using (AESDatabaseDataContext db = new AESDatabaseDataContext())
                {
                    IList<School> schools = db.Schools.ToList();
                    List<SchoolDAO> result = new List<SchoolDAO>();
                    foreach (var school in schools)
                    {
                        SchoolDAO temp = new SchoolDAO
                        {
                            SchoolID = school.School_ID,
                            SchoolName = school.School_Name,
                            SchoolAddress = school.School_Address
                        };

                        result.Add(temp);
                    }

                    return (result != null ? result : null);
                }
            }
            catch (Exception e)
            {
                throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
            }
        }
 public SchoolDAO GetSchoolByID(int id)
 {
     try
     {
         using (AESDatabaseDataContext db = new AESDatabaseDataContext())
         {
             School school = (from sch in db.Schools where sch.School_ID == id select sch).FirstOrDefault();
             SchoolDAO result = new SchoolDAO
             {
                 SchoolID = school.School_ID,
                 SchoolName = school.School_Name,
                 SchoolAddress = school.School_Address
             };
             return (result != null ? result : null);
         }
     }
     catch (Exception e)
     {
         throw new FaultException<KaskServiceException>(new KaskServiceException(), new FaultReason(e.Message));
     }
 }
예제 #10
0
 public bool CreateSchool(SchoolDAO e)
 {
     Schools.Add(e);
     return true;
 }