Esempio n. 1
0
        // Update student
        public Student UpdateStudent(Student model)
        {
            Student student = DB.Students.Where(s => s.Id == model.Id).SingleOrDefault();

            if (student != null)
            {
                DB.Entry(student).CurrentValues.SetValues(model);
                DB.SaveChanges();
                return(model);
            }
            return(null);
        }
Esempio n. 2
0
        // Update subject
        public Subject UpdateSubject(Subject model)
        {
            Subject subject = DB.Subjects.Where(s => s.Id == model.Id).SingleOrDefault();

            if (subject != null)
            {
                DB.Entry(subject).CurrentValues.SetValues(model);
                DB.SaveChanges();
                return(model);
            }
            return(null);
        }