public bool Update(Student student) { DbContextSMS db = new DbContextSMS(); db.Parents.Attach(student.Parent); db.Entry(student.Parent).State = EntityState.Modified; bool isUpdate = db.SaveChanges() > 0; db.BankAccounts.Attach(student.BankAccount); db.Entry(student.BankAccount).State = EntityState.Modified; isUpdate = db.SaveChanges() > 0; List <Image> imgList = student.Images; student.Images = null; student.BankAccount = null; foreach (var skl in student.Skills) { DbContextSMS dbCon = new DbContextSMS(); dbCon.Skills.Attach(skl); dbCon.Entry(skl).State = EntityState.Modified; dbCon.SaveChanges(); } student.Skills = null; db.Students.Attach(student); db.Entry(student).State = EntityState.Modified; isUpdate = db.SaveChanges() > 0; //add all images if (imgList.Count > 0) { foreach (var img in imgList) { Image imgObj = new Image() { StudentId = student.Id, FileName = img.FileName }; db.Images.Add(imgObj); db.SaveChanges(); } } return(isUpdate); }
public bool Update(Department department) { DbContextSMS db = new DbContextSMS(); db.Departments.Attach(department); db.Entry(department).State = EntityState.Modified; return(db.SaveChanges() > 0); }
public bool Update(Sesion session) { DbContextSMS db = new DbContextSMS(); db.Sessions.Attach(session); db.Entry(session).State = EntityState.Modified; return(db.SaveChanges() > 0); }
public bool Update(Bank bank) { DbContextSMS db = new DbContextSMS(); db.Banks.Attach(bank); db.Entry(bank).State = EntityState.Modified; return(db.SaveChanges() > 0); }
public bool Update(Country country) { DbContextSMS db = new DbContextSMS(); db.Countries.Attach(country); db.Entry(country).State = EntityState.Modified; return(db.SaveChanges() > 0); }
public bool Update(Semister semister) { DbContextSMS db = new DbContextSMS(); db.Semisters.Attach(semister); db.Entry(semister).State = EntityState.Modified; return(db.SaveChanges() > 0); }