public bool DeleteDvd(int dvdId) { try { Dvd dvd = GetDvd(dvdId); using (var ctx = new DvdContext()) { ctx.Entry(dvd).State = System.Data.Entity.EntityState.Deleted; ctx.SaveChanges(); } return(true); } catch (Exception e) { return(false); } }
public bool UpdateDvd(Dvd dvd) { try { using (var ctx = new DvdContext()) { //dvd.Director = DirectorRepositoryEF.GetDirectorbyId(dvd.DirectorId); //dvd.Rating = RateRepositoryEF.GetRatebyId(dvd.RatingId); ctx.Entry(dvd).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); dvd.Director = DirectorFactory.Create().GetDirectorbyId(dvd.DirectorId); dvd.Rating = RatingFactory.Create().GetRatingbyId(dvd.RatingId); return(true); } } catch (Exception e) { return(false); } }