コード例 #1
0
        public IHttpActionResult Get(int id)
        {
            var result = classRepo.GetById(id);

            if (result == null)
            {
                return(Content(HttpStatusCode.NotFound, "Item does not exist"));
            }
            return(Ok(result));
        }
コード例 #2
0
        public void EnrollStudent(int classid, int studentid)
        {
            var student     = studentRepo.GetById(studentid);
            var classresult = classRepo.GetById(classid);

            classresult.Students.Add(student);
            unit.SaveChanges();

            //var student1 = _context.Set<Student>().FirstOrDefault(s => s.FirstName == "bobby");
            //var class1 = _context.Set<Class>().Find(3);
            //class1.Students.Add(student1);

            //_context.SaveChanges();
        }