Esempio n. 1
0
        //UPDATED STUDENT PER COURSE

        static public List <Course> CourseById()
        {
            using (SchoolProject2Context db = new SchoolProject2Context())
            {
                return(db.Courses.ToList());
            }
        }
Esempio n. 2
0
 // READ
 static public List <Student> GetAllStudents()
 {
     using (SchoolProject2Context db = new SchoolProject2Context())
     {
         return(db.Students.ToList());
     }
 }
Esempio n. 3
0
 static public List <Trainer> GetAllTrainers()
 {
     using (SchoolProject2Context db = new SchoolProject2Context())
     {
         return(db.Trainers.ToList());
     }
 }
Esempio n. 4
0
 static public List <Assignment> GetAllAssignments()
 {
     using (SchoolProject2Context db = new SchoolProject2Context())
     {
         return(db.Assignments.ToList());
     }
 }
Esempio n. 5
0
 static public void AssingmnetPerCourse(int id)
 {
     using (SchoolProject2Context db = new SchoolProject2Context())
     {
         Assignment    assignment = db.Assignments.Find(id);
         List <Course> course     = assignment.Courses.ToList();
     }
 }
Esempio n. 6
0
 public static Student FindPassword(string Username)
 {
     using (SchoolProject2Context db = new SchoolProject2Context())
     {
         var query = db.Students.Where(x => x.Username == Username).FirstOrDefault <Student>();
         return(query);
     }
 }
Esempio n. 7
0
 //STUDENT PER COURSE UPDATED
 static public void StudentPerCourse(int id)
 {
     using (SchoolProject2Context db = new SchoolProject2Context())
     {
         Student       student = db.Students.Find(id);
         List <Course> course  = student.Courses.ToList();
     }
 }
Esempio n. 8
0
 static public void TrainerPerCourse(int id)
 {
     using (SchoolProject2Context db = new SchoolProject2Context())
     {
         Trainer       trainer = db.Trainers.Find(id);
         List <Course> course  = trainer.Courses.ToList();
     }
 }
Esempio n. 9
0
 static public void UpdateTrainer(int id, string firstname, string lastname, string subject)
 {
     using (SchoolProject2Context db = new SchoolProject2Context())
     {
         Trainer TrainerToUpdate = db.Trainers.Find(id);
         TrainerToUpdate.FirstName = firstname;
         TrainerToUpdate.LastName  = lastname;
         TrainerToUpdate.Subject   = subject;
         db.SaveChanges();
     }
 }
Esempio n. 10
0
 static public void UpdateAssignment(int id, string title, string description, DateTime submission, int oralmark, int totalmark)
 {
     using (SchoolProject2Context db = new SchoolProject2Context())
     {
         Assignment AssignmentToUpdate = db.Assignments.Find(id);
         AssignmentToUpdate.Title       = title;
         AssignmentToUpdate.Description = description;
         AssignmentToUpdate.OralMark    = oralmark;
         AssignmentToUpdate.TotalMark   = totalmark;
         db.SaveChanges();
     }
 }
Esempio n. 11
0
 //UPDATE
 static public void UpdateStudent(int id, string firstname, string lastname, DateTime date_of_birth, decimal tuition_fees)
 {
     using (SchoolProject2Context db = new SchoolProject2Context())
     {
         Student StudentToUpdate = db.Students.Find(id);
         StudentToUpdate.FirstName   = firstname;
         StudentToUpdate.LastName    = lastname;
         StudentToUpdate.DateOfBirth = date_of_birth;
         StudentToUpdate.TuitionFees = tuition_fees;
         db.SaveChanges();
     }
 }
Esempio n. 12
0
 //DELETE
 static public void DeleteAssignment(int id)
 {
     using (SchoolProject2Context db = new SchoolProject2Context())
     {
         Assignment AssignmentToDelete = db.Assignments.Find(id);
         if (AssignmentToDelete == null)
         {
             return;
         }
         db.Assignments.Remove(AssignmentToDelete);
         db.SaveChanges();
     }
 }
Esempio n. 13
0
 static public void UpdateCourse(int id, string title, string stream, string type, DateTime startdate, DateTime enddate)
 {
     using (SchoolProject2Context db = new SchoolProject2Context())
     {
         Course CourseToUpdate = db.Courses.Find(id);
         CourseToUpdate.Title     = title;
         CourseToUpdate.Stream    = stream;
         CourseToUpdate.Type      = type;
         CourseToUpdate.StartDate = startdate;
         CourseToUpdate.EndDate   = enddate;
         db.SaveChanges();
     }
 }
Esempio n. 14
0
 //DELETE
 static public void DeleteCourse(int id)
 {
     using (SchoolProject2Context db = new SchoolProject2Context())
     {
         Course CourseToDelete = db.Courses.Find(id);
         if (CourseToDelete == null)
         {
             return;
         }
         db.Courses.Remove(CourseToDelete);
         db.SaveChanges();
     }
 }
Esempio n. 15
0
 //DELETE
 static public void DeleteTrainer(int id)
 {
     using (SchoolProject2Context db = new SchoolProject2Context())
     {
         Trainer TrainerToDelete = db.Trainers.Find(id);
         if (TrainerToDelete == null)
         {
             return;
         }
         db.Trainers.Remove(TrainerToDelete);
         db.SaveChanges();
     }
 }
Esempio n. 16
0
 public static void CreateAccount(int Id, string Username, string Password)
 {
     using (SchoolProject2Context db = new SchoolProject2Context())
     {
         Student student = db.Students.Find(Id);
         if (student == null)
         {
             Console.WriteLine("Nothing.");
             return;
         }
         student.Username = Username;
         student.Password = Password;
         db.SaveChanges();
     }
 }
Esempio n. 17
0
        static public int CreateTrainer(string firstname, string lastname, string subject)
        {
            Trainer trainer = new Trainer()
            {
                FirstName = firstname,
                LastName  = lastname,
                Subject   = subject,
            };

            using (SchoolProject2Context db = new SchoolProject2Context())
            {
                db.Trainers.Add(trainer);
                db.SaveChanges();
            }
            return(trainer.Id);
        }
Esempio n. 18
0
        //CREATE
        static public int CreateStudent(string firstname, string lastname, DateTime date_of_birth, decimal tuition_fees)
        {
            Student student = new Student()
            {
                FirstName   = firstname,
                LastName    = lastname,
                DateOfBirth = date_of_birth,
                TuitionFees = tuition_fees
            };

            using (SchoolProject2Context db = new SchoolProject2Context())
            {
                db.Students.Add(student);
                db.SaveChanges();
            }
            return(student.Id);
        }
Esempio n. 19
0
        static public int CreateAssignment(string title, string description, DateTime submission, int oralmark, int totalmark)
        {
            Assignment assignment = new Assignment()
            {
                Title                 = title,
                Description           = description,
                SubmissionDateAndTime = submission,
                OralMark              = oralmark,
                TotalMark             = totalmark,
            };

            using (SchoolProject2Context db = new SchoolProject2Context())
            {
                db.Assignments.Add(assignment);
                db.SaveChanges();
            }
            return(assignment.Id);
        }
Esempio n. 20
0
        static public int CreateCourse(string title, string stream, string type, DateTime startdate, DateTime enddate)
        {
            Course course = new Course()
            {
                Title     = title,
                Stream    = stream,
                Type      = type,
                StartDate = startdate,
                EndDate   = enddate
            };

            using (SchoolProject2Context db = new SchoolProject2Context())
            {
                db.Courses.Add(course);
                db.SaveChanges();
            }
            return(course.Id);
        }