public void EditDvd(Dvd dvd, int id) { DvdLibraryEFEntities db = new DvdLibraryEFEntities(); dvd.DvdId = id; db.Dvds.AddOrUpdate(d => d.DvdId, dvd); db.SaveChanges(); }
public void DeleteDvd(int id) { DvdLibraryEFEntities db = new DvdLibraryEFEntities(); var target = db.Dvds.Find(id); if (target != null) { db.Dvds.Remove(target); } db.SaveChanges(); }
public void AddDvd(Dvd dvd) { DvdLibraryEFEntities db = new DvdLibraryEFEntities(); //IEnumerable<DbEntityValidationResult> validation = db.GetValidationErrors(); bool valid = (dvd.Title != null && dvd.RealeaseYear > 0 && dvd.Director != null && dvd.Rating != null); //foreach (var v in validation) //{ // valid = v.IsValid; //} if (valid) { db.Dvds.AddOrUpdate(dvd); db.SaveChanges(); } }