public List <Photo> GetAll() { using (PhotoAlbumDbContext ctx = new PhotoAlbumDbContext()) { return(ctx.Photos.Include(x => x.Resolution).ToList()); } }
public ActionResult Index() { List <Album> albums = new List <Album>(); using (PhotoAlbumDbContext ctx = new PhotoAlbumDbContext()) { albums = ctx.Albums.ToList(); } return(View(albums)); }
public ActionResult Index() { List <Person> people = new List <Person>(); using (PhotoAlbumDbContext ctx = new PhotoAlbumDbContext()) { people = ctx.People.ToList(); } return(View(people)); }
public ActionResult Index() { List <Item> items = new List <Item>(); using (PhotoAlbumDbContext ctx = new PhotoAlbumDbContext()) { items = ctx.Items.ToList(); } return(View(items)); }
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 Photo Get(int id) { if (id < 0) { return(null); } using (PhotoAlbumDbContext ctx = new PhotoAlbumDbContext()) { return(ctx.Photos.Include(x => x.Resolution).ToList().Find(x => x.Id == id)); } }
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(); } }