Esempio n. 1
0
        public IHttpActionResult AddStudent(Guid courseId, StudentServiceModel studentModel)
        {
            if (!this.ModelState.IsValid)
            {
                return(BadRequest(this.ModelState));
            }

            var course = this.GetCourseById(courseId);

            course.Students.Add(studentModel.ConverToStudent());
            this.data.SaveChanges();

            return(Ok(CourseServiceModel.ConvertFromCourse(course)));
        }
        public IHttpActionResult AddStudent(StudentServiceModel newStudent)
        {
            if (!this.ModelState.IsValid)
            {
                return(BadRequest(this.ModelState));
            }

            Student student = newStudent.ConverToStudent();

            this.data.Students.Add(student);
            this.data.SaveChanges();

            newStudent.Id = student.StudentId;
            return(Ok(newStudent));
        }