Ejemplo n.º 1
0
 public Image GetImage(int id)
 {
     using (var context = new ImageDataContext(_connectionString))
     {
         return(context.Images.FirstOrDefault(i => i.Id == id));
     }
 }
Ejemplo n.º 2
0
 public IEnumerable <Image> GetImages()
 {
     using (var context = new ImageDataContext(_connectionString))
     {
         return(context.Images.OrderByDescending(i => i.Id).ToList());
     }
 }
Ejemplo n.º 3
0
 public void AddImage(Image image)
 {
     using (var context = new ImageDataContext(_connectionString))
     {
         context.Images.InsertOnSubmit(image);
         context.SubmitChanges();
     }
 }
Ejemplo n.º 4
0
 public void AddLike(int id)
 {
     using (var context = new ImageDataContext(_connectionString))
     {
         Image image = GetImage(id);
         image.Likes = image.Likes + 1;
         context.Images.Attach(image);
         context.Refresh(System.Data.Linq.RefreshMode.KeepCurrentValues, image);
         context.SubmitChanges();
     }
 }