Example #1
0
 public Users GetAdmin(string UserName, string Password)
 {
     using (ahmetDatabaseEntities studentSystemEntities = new ahmetDatabaseEntities())
     {
         return(studentSystemEntities.Users.FirstOrDefault(x => x.UserName == UserName && x.Password == Password));
     }
 }
Example #2
0
 // GET api/GetCourseByID/5
 public Courses Get(int id)
 {
     using (ahmetDatabaseEntities studentSystemEntities = new ahmetDatabaseEntities())
     {
         Console.WriteLine("get");
         return(studentSystemEntities.Courses.FirstOrDefault(x => x.ID == id));
     }
 }
Example #3
0
 // GET api/Courses
 public IEnumerable <Courses> Get()
 {
     using (ahmetDatabaseEntities studentSystemEntities = new ahmetDatabaseEntities())
     {
         Console.WriteLine("get");
         return(studentSystemEntities.Courses.ToList());
     }
 }
Example #4
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();
     }
 }
Example #5
0
 // POST api/Courses
 public void Post([FromBody] Courses sub)
 {
     using (ahmetDatabaseEntities studentSystemEntities = new ahmetDatabaseEntities())
     {
         Console.WriteLine("get");
         studentSystemEntities.Courses.Add(sub);
         studentSystemEntities.SaveChanges();
     }
 }
Example #6
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();
     }
 }
Example #7
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();
     }
 }
Example #8
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();
     }
 }
Example #9
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();
     }
 }
Example #10
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");
            }
        }
Example #11
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();
            }
        }