Exemplo n.º 1
0
 public List <Photo> GetAll()
 {
     using (PhotoAlbumDbContext ctx = new PhotoAlbumDbContext())
     {
         return(ctx.Photos.Include(x => x.Resolution).ToList());
     }
 }
Exemplo n.º 2
0
        public ActionResult Index()
        {
            List <Album> albums = new List <Album>();

            using (PhotoAlbumDbContext ctx = new PhotoAlbumDbContext())
            {
                albums = ctx.Albums.ToList();
            }
            return(View(albums));
        }
Exemplo n.º 3
0
        public ActionResult Index()
        {
            List <Person> people = new List <Person>();

            using (PhotoAlbumDbContext ctx = new PhotoAlbumDbContext())
            {
                people = ctx.People.ToList();
            }
            return(View(people));
        }
Exemplo n.º 4
0
        public ActionResult Index()
        {
            List <Item> items = new List <Item>();

            using (PhotoAlbumDbContext ctx = new PhotoAlbumDbContext())
            {
                items = ctx.Items.ToList();
            }
            return(View(items));
        }
Exemplo n.º 5
0
 public void Remove(IList <Photo> items)
 {
     using (PhotoAlbumDbContext ctx = new PhotoAlbumDbContext())
     {
         foreach (Photo p in items)
         {
             ctx.Photos.Remove(p);
         }
         ctx.SaveChanges();
     }
 }
Exemplo n.º 6
0
 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();
     }
 }
Exemplo n.º 7
0
        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));
            }
        }
Exemplo n.º 8
0
        public void Remove(Photo item)
        {
            if (item == null)
            {
                return;
            }

            using (PhotoAlbumDbContext ctx = new PhotoAlbumDbContext())
            {
                ctx.Photos.Remove(item);
                ctx.SaveChanges();
            }
        }
Exemplo n.º 9
0
 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();
     }
 }