public object GetService(Type serviceType) { if (serviceType == typeof(StudentsController)) { var context = new StudentsDbEntities(); var repository = new DbStudentRepository(context); return(new StudentsController(repository)); } else if (serviceType == typeof(SchoolsController)) { var context = new StudentsDbEntities(); var repository = new DbSchoolRepository(context); return(new SchoolsController(repository)); } else if (serviceType == typeof(MarksController)) { var context = new StudentsDbEntities(); var repository = new DbMarkRepository(context); return(new MarksController(repository)); } else { return(null); } }
public IQueryable <MarkModel> Get(int id) { StudentsDbEntities context = new StudentsDbEntities(); IQueryable <MarkModel> marksDetails = (from mark in context.Marks where mark.StudentId == id select new MarkModel() { Subject = mark.Subject, Score = mark.Score }); return(marksDetails); }
// GET api/students public IQueryable <StudentModel> Get() { StudentsDbEntities context = new StudentsDbEntities(); IQueryable <StudentModel> studentsDetails = (from student in context.Students select new StudentModel() { FirstName = student.FirstName, LastName = student.LastName, Grade = student.Grade, Age = student.Age, Marks = (from mark in student.Marks select new MarkModel() { Subject = mark.Subject, Score = mark.Score }) }); return(studentsDetails); }