public static Student ToStudent(this StudentRequest newStudent, int houseId)
 {
     return(new Student()
     {
         StudentName = newStudent.StudentName,
         HouseId = houseId
     });
 }
Esempio n. 2
0
        public Student InsertStudent(int houseId, StudentRequest newStudent)
        {
            Student studentToInsert = newStudent.ToStudent(houseId);

            try
            {
                var result = _potterContext.students.Add(studentToInsert);


                var saves = _potterContext.SaveChanges();

                return(studentToInsert);
            } catch (DbUpdateException err)
            {
                var code = err.InnerException;

                throw err;
            }
        }