public static IStudent ToStudent(this StudentEntity entity)
        {
            IStudent s = null;

            if (entity != null)
            {
                s = new Student
                {
                    FirstName = entity.FirstName,
                    LastName = entity.LastName,
                    MicrosoftId = entity.RowKey
                };
            }
            return s;
        }
Example #2
0
        public IHttpActionResult AddStudent(int id, Student newStudent)
        {
            ICourse course = db.GetCourse(id);

            if (course == null)
            {
                return NotFound();
            }

            IStudent student = db.GetStudent(newStudent.MicrosoftId);

            if (student == null)
            {
                student = db.AddStudent(newStudent);
            }

            db.AddStudentToCourse(student, course);

            return Ok();
        }