예제 #1
0
        public IActionResult DeleteStudent(string indexNumber)
        {
            var db      = new s19981Context();
            var student = new Student
            {
                IndexNumber = indexNumber
            };

            db.Attach(student);
            db.Remove(student);

            db.SaveChanges();

            return(Ok());
        }
예제 #2
0
        public IActionResult UpdateStudent(string indexNumber, string firstName, string lastName)
        {
            var db      = new s19981Context();
            var student = new Student
            {
                IndexNumber = indexNumber,
                FirstName   = firstName,
                LastName    = lastName
            };

            db.Attach(student);
            db.Entry(student).Property("FirstName").IsModified = true;
            db.Entry(student).Property("LastName").IsModified  = true;
            db.SaveChanges();

            return(Ok(student));
        }