예제 #1
0
 public void AddNewPhoto(PhotoDataModel photo)
 {
     using (TheContext ctx = new TheContext())
     {
         ctx.Photos.Add(photo);
         ctx.SaveChanges();
     }
 }
예제 #2
0
 public void SavePhotoInAlbum(Guid id, PhotoDataModel photo)
 {
     using (TheContext ctx = new TheContext())
     {
         var album = ctx.Albums.Include("Photos").FirstOrDefault(a => a.AlbumId == id);
         album.Photos.Add(photo);
         ctx.SaveChanges();
     }
 }