Exemplo n.º 1
0
 // DELETE api/Courses/id
 public void Delete(int courseID)
 {
     using (ahmetDatabaseEntities studentSystemEntities = new ahmetDatabaseEntities())
     {
         Courses course = studentSystemEntities.Courses.FirstOrDefault(x => x.ID == courseID);
         studentSystemEntities.Courses.Remove(course);
         studentSystemEntities.SaveChanges();
     }
 }
Exemplo n.º 2
0
 // POST api/Courses
 public void Post([FromBody] Courses sub)
 {
     using (ahmetDatabaseEntities studentSystemEntities = new ahmetDatabaseEntities())
     {
         Console.WriteLine("get");
         studentSystemEntities.Courses.Add(sub);
         studentSystemEntities.SaveChanges();
     }
 }
Exemplo n.º 3
0
 // DELETE api/Teachers/id
 public void Delete(int teacherID)
 {
     using (ahmetDatabaseEntities studentSystemEntities = new ahmetDatabaseEntities())
     {
         Teachers teacher = studentSystemEntities.Teachers.FirstOrDefault(x => x.ID == teacherID);
         studentSystemEntities.Teachers.Remove(teacher);
         studentSystemEntities.SaveChanges();
     }
 }
Exemplo n.º 4
0
 // DELETE api/Students/id
 public void Delete(int studentID)
 {
     using (ahmetDatabaseEntities studentSystemEntities = new ahmetDatabaseEntities())
     {
         Students student = studentSystemEntities.Students.FirstOrDefault(x => x.ID == studentID);
         studentSystemEntities.Students.Remove(student);
         studentSystemEntities.SaveChanges();
     }
 }
Exemplo n.º 5
0
 public void PutCourseByID(int courseID, string startTime, string endTime, string context)
 {
     using (ahmetDatabaseEntities studentSystemEntities = new ahmetDatabaseEntities())
     {
         Courses course = studentSystemEntities.Courses.FirstOrDefault(x => x.ID == courseID);
         course.CourseStartTime = startTime;
         course.CourseEndTime   = endTime;
         course.Context         = context;
         studentSystemEntities.SaveChanges();
     }
 }
Exemplo n.º 6
0
 // PUT api/Courses/5
 public void PutEnrollment(int courseID, int studentID)
 {
     using (ahmetDatabaseEntities studentSystemEntities = new ahmetDatabaseEntities())
     {
         Courses  course  = studentSystemEntities.Courses.FirstOrDefault(x => x.ID == courseID);
         Students student = studentSystemEntities.Students.FirstOrDefault(x => x.ID == studentID);
         course.NumberOfEnrollments = course.NumberOfEnrollments + 1;
         course.EnrolledStudents    = course.EnrolledStudents + "," + student.StudentName + " " + student.StudentSurname;
         student.EnrolledCourses    = student.EnrolledCourses + "," + course.CourseName;
         studentSystemEntities.SaveChanges();
     }
 }
Exemplo n.º 7
0
        public string GetEnrollment(string courseID, string studentID)
        {
            using (ahmetDatabaseEntities studentSystemEntities = new ahmetDatabaseEntities())
            {
                int courseIDx  = Int16.Parse(courseID);
                int studentIDx = Int16.Parse(studentID);

                Courses  course  = studentSystemEntities.Courses.FirstOrDefault(x => x.ID == courseIDx);
                Students student = studentSystemEntities.Students.FirstOrDefault(x => x.ID == studentIDx);
                course.NumberOfEnrollments = course.NumberOfEnrollments + 1;
                course.EnrolledStudents    = course.EnrolledStudents + "," + student.StudentName + " " + student.StudentSurname;
                student.EnrolledCourses    = student.EnrolledCourses + "," + course.CourseName;
                studentSystemEntities.SaveChanges();
                return("ok");
            }
        }
Exemplo n.º 8
0
        public void PutDisEnrollment(int courseID, int studentID)
        {
            using (ahmetDatabaseEntities studentSystemEntities = new ahmetDatabaseEntities())

            {
                Courses  course  = studentSystemEntities.Courses.FirstOrDefault(x => x.ID == courseID);
                Students student = studentSystemEntities.Students.FirstOrDefault(x => x.ID == studentID);

                course.NumberOfEnrollments = course.NumberOfEnrollments - 1;

                List <string> words = course.EnrolledStudents.Split(',').ToList();
                words.Remove(student.StudentName + " " + student.StudentSurname);
                course.EnrolledStudents = String.Join(",", words.ToArray());

                List <string> words2 = student.EnrolledCourses.Split(',').ToList();
                words2.Remove(course.CourseName);
                student.EnrolledCourses = String.Join(",", words2.ToArray());

                studentSystemEntities.SaveChanges();
            }
        }