public void Remove(IList <Photo> items) { using (PhotoAlbumDbContext ctx = new PhotoAlbumDbContext()) { foreach (Photo p in items) { ctx.Photos.Remove(p); } ctx.SaveChanges(); } }
public void Add(Photo item) { using (PhotoAlbumDbContext ctx = new PhotoAlbumDbContext()) { ctx.Photos.Add(item); item.Resolution.Photo = item; item.Resolution.PhotoId = item.Id; ctx.Resolutions.Add(item.Resolution); ctx.SaveChanges(); } }
public void Remove(Photo item) { if (item == null) { return; } using (PhotoAlbumDbContext ctx = new PhotoAlbumDbContext()) { ctx.Photos.Remove(item); ctx.SaveChanges(); } }
public void Add(IList <Photo> items) { using (PhotoAlbumDbContext ctx = new PhotoAlbumDbContext()) { foreach (Photo p in items) { ctx.Photos.Add(p); p.Resolution.Photo = p; p.Resolution.PhotoId = p.Id; ctx.Resolutions.Add(p.Resolution); } ctx.SaveChanges(); } }