예제 #1
0
 public bool AddStudent(AddEditStudentDto studentDto)
 {
     try
     {
         StudentCourse stdCourse = new StudentCourse();
         Student       s         = new Student();
         s.Name            = studentDto.Name;
         s.FName           = studentDto.FName;
         s.Dob             = studentDto.Dob;
         s.Email           = studentDto.Email;
         s.Phone           = studentDto.Phone;
         s.Password        = studentDto.Password;
         s.ImageUrl        = studentDto.ImageUrl;
         s.ThumbUrl        = studentDto.ThumbUrl;
         s.ConfirmPassword = studentDto.ConfirmPassword;
         s.UserId          = studentDto.UserId;
         context.Students.Add(s);
         List <StudentCourse> courseList = new List <StudentCourse>();
         if (studentDto.Courses != null)
         {
             foreach (var Course in studentDto.Courses)
             {
                 StudentCourse course_Obj = new StudentCourse();
                 course_Obj.StudentId = s.Id;
                 course_Obj.CourseId  = Convert.ToInt32(Course);
                 courseList.Add(course_Obj);
             }
             context.StudentCourses.AddRange(courseList);
         }
         context.SaveChanges();
     }
     catch (Exception e)
     {
         return(false);
     }
     return(true);
 }
예제 #2
0
 public void Save()
 {
     _context.SaveChanges();
 }