コード例 #1
0
ファイル: Program.cs プロジェクト: sellnat77/DotNetApps
 static bool createStandard(Standard stndrd)
 {
     //Add standard to db
     using (var contxt = new SchoolDBEntities())
     {
         contxt.Standards.Add(stndrd);
         contxt.SaveChanges();
     }
     return(true);
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: sellnat77/DotNetApps
 static bool createStudent(Student student)
 {
     //Adds student to db
     using (var contxt = new SchoolDBEntities())
     {
         contxt.Students.Add(student);
         contxt.SaveChanges();
     }
     return(true);
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: sellnat77/DotNetApps
 static bool createTeacher(Teacher teach)
 {
     //Add teacher to db
     using (var contxt = new SchoolDBEntities())
     {
         contxt.Teachers.Add(teach);
         contxt.SaveChanges();
     }
     return true;
 }
コード例 #4
0
ファイル: Program.cs プロジェクト: sellnat77/DotNetApps
 static bool createStudent(Student student)
 {
     //Adds student to db
     using (var contxt = new SchoolDBEntities())
     {
         contxt.Students.Add(student);
         contxt.SaveChanges();
     }
     return true;
 }
コード例 #5
0
ファイル: Program.cs プロジェクト: sellnat77/DotNetApps
 static bool createStandard(Standard stndrd)
 {
     //Add standard to db
     using (var contxt = new SchoolDBEntities())
     {
         contxt.Standards.Add(stndrd);
         contxt.SaveChanges();
     }
     return true;
 }
コード例 #6
0
ファイル: Program.cs プロジェクト: sellnat77/DotNetApps
        static bool deleteStudentAddr(String studentName)
        {
            //Removes a particular students address
            Student toDel;
            var     contxt = new SchoolDBEntities();

            toDel = contxt.Students.Where(st => st.StudentName == studentName).FirstOrDefault <Student>();
            contxt.Entry(toDel.StudentAddress).State = System.Data.Entity.EntityState.Deleted;
            contxt.SaveChanges();
            return(true);
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: sellnat77/DotNetApps
        static bool deleteStudentAddr(String studentName)
        {
            //Removes a particular students address
            Student toDel;
            var contxt = new SchoolDBEntities();

            toDel = contxt.Students.Where(st => st.StudentName == studentName).FirstOrDefault<Student>();
            contxt.Entry(toDel.StudentAddress).State = System.Data.Entity.EntityState.Deleted;
            contxt.SaveChanges();
            return true;
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: sellnat77/DotNetApps
        static bool updateStandard(String standardName, String newDescription)
        {
            //Change standard description based on what is passed in
            var      contxt = new SchoolDBEntities();
            Standard toUpdate;

            toUpdate = contxt.Standards.Where(st => st.StandardName == standardName).FirstOrDefault <Standard>();

            if (toUpdate != null)
            {
                toUpdate.Description = newDescription;
            }
            else
            {
                return(false);
            }
            contxt.Entry(toUpdate).State = System.Data.Entity.EntityState.Modified;
            contxt.SaveChanges();

            return(true);
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: sellnat77/DotNetApps
        static bool updateStudent(String studentName, String newAddr)
        {
            //Updates a student based on whats passed in to the function
            var     contxt = new SchoolDBEntities();
            Student toUpdate;

            toUpdate = contxt.Students.Where(st => st.StudentName == studentName).FirstOrDefault <Student>();

            if (toUpdate != null)
            {
                toUpdate.StudentAddress.Address1 = newAddr;
            }
            else
            {
                return(false);
            }
            contxt.Entry(toUpdate).State = System.Data.Entity.EntityState.Modified;
            contxt.SaveChanges();

            return(true);
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: sellnat77/DotNetApps
        static bool updateStudentDisconnect(String studentName, String newAddr)
        {
            Student toUpdate;

            //Update student address in disconnected mode
            using (var contxt = new SchoolDBEntities())
            {
                toUpdate = contxt.Students.Where(st => st.StudentName == studentName).FirstOrDefault <Student>();
            }
            if (toUpdate != null)
            {
                toUpdate.StudentAddress.Address1 = newAddr;
            }
            else
            {
                return(false);
            }
            using (var contxt1 = new SchoolDBEntities())
            {
                contxt1.Entry(toUpdate).State = System.Data.Entity.EntityState.Modified;
                contxt1.SaveChanges();
            }
            return(true);
        }
コード例 #11
0
ファイル: Program.cs プロジェクト: sellnat77/DotNetApps
        static bool updateTeachIDDisconnect(Teacher toChange, Teacher changeTo)
        {
            //Change standard description based on what is passed in
            //Disconnected mode
            Teacher toUpdate;
            Teacher change;
            using (var contxt = new SchoolDBEntities())
            {
                toUpdate = contxt.Teachers.Where(st => st.TeacherName == toChange.TeacherName).FirstOrDefault<Teacher>();
                change = contxt.Teachers.Where(st => st.TeacherName == changeTo.TeacherName).FirstOrDefault<Teacher>();
            }

            if (toUpdate != null && change != null)
            {
                toUpdate.StandardId = change.StandardId;
            }
            else
            {
                return false;
            }

            using (var contxt1 = new SchoolDBEntities())
            {
                contxt1.Entry(toUpdate).State = System.Data.Entity.EntityState.Modified;
                contxt1.SaveChanges();
            }
            return true;
        }
コード例 #12
0
ファイル: Program.cs プロジェクト: sellnat77/DotNetApps
        static bool updateTeachID(Teacher toChange, Teacher changeTo)
        {
            //Change standard description based on what is passed in
            var contxt = new SchoolDBEntities();
            Teacher toUpdate;
            Teacher change;

            toUpdate = contxt.Teachers.Where(st => st.TeacherName== toChange.TeacherName).FirstOrDefault<Teacher>();
            change = contxt.Teachers.Where(st => st.TeacherName == changeTo.TeacherName).FirstOrDefault<Teacher>();

            if (toUpdate != null)
            {
                toUpdate.StandardId = change.StandardId;
            }
            else
            {
                return false;
            }
            contxt.Entry(toUpdate).State = System.Data.Entity.EntityState.Modified;
            contxt.SaveChanges();

            return true;
        }
コード例 #13
0
ファイル: Program.cs プロジェクト: sellnat77/DotNetApps
 static bool updateStudentDisconnect(String studentName, String newAddr)
 {
     Student toUpdate;
     //Update student address in disconnected mode
     using (var contxt = new SchoolDBEntities())
     {
         toUpdate = contxt.Students.Where(st => st.StudentName == studentName).FirstOrDefault<Student>();
     }
     if (toUpdate != null)
     {
         toUpdate.StudentAddress.Address1 = newAddr;
     }
     else
     {
         return false;
     }
     using (var contxt1 = new SchoolDBEntities())
     {
         contxt1.Entry(toUpdate).State = System.Data.Entity.EntityState.Modified;
         contxt1.SaveChanges();
     }
     return true;
 }
コード例 #14
0
ファイル: Program.cs プロジェクト: sellnat77/DotNetApps
        static bool updateStudent(String studentName, String newAddr)
        {
            //Updates a student based on whats passed in to the function
            var contxt = new SchoolDBEntities();
            Student toUpdate;

            toUpdate = contxt.Students.Where(st => st.StudentName == studentName).FirstOrDefault<Student>();

            if(toUpdate != null)
            {
                toUpdate.StudentAddress.Address1 = newAddr;
            }
            else
            {
                return false;
            }
            contxt.Entry(toUpdate).State = System.Data.Entity.EntityState.Modified;
            contxt.SaveChanges();

            return true;
        }
コード例 #15
0
ファイル: Program.cs プロジェクト: sellnat77/DotNetApps
        static bool updateStandard(String standardName, String newDescription)
        {
            //Change standard description based on what is passed in
            var contxt = new SchoolDBEntities();
            Standard toUpdate;

            toUpdate = contxt.Standards.Where(st => st.StandardName == standardName).FirstOrDefault<Standard>();

            if (toUpdate != null)
            {
                toUpdate.Description = newDescription;
            }
            else
            {
                return false;
            }
            contxt.Entry(toUpdate).State = System.Data.Entity.EntityState.Modified;
            contxt.SaveChanges();

            return true;
        }