예제 #1
0
 public bool UpdateImage(FullImageWithThumbnail image)
 {
     try
     {
         using (ImagesDatabaseEntities context = new ImagesDatabaseEntities())
         {
             Image updateImage = context.Images.FirstOrDefault(i => i.Id == image.Id);
             if (updateImage != null)
             {
                 UpdateImageWithNewData(updateImage, image);
                 bool result = context.SaveChanges() > 0;
                 return(result);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception ex)
     {
         //logger
         return(false);
     }
 }
예제 #2
0
 public FullImage GetImage(Guid imageId)
 {
     try
     {
         using (ImagesDatabaseEntities context = new ImagesDatabaseEntities())
         {
             FullImage result = context.Images.Where(i => i.Id == imageId)
                                .Select(i => new FullImage {
                 Id = i.Id, ImageName = i.ImageName, FullImageData = i.Data
             })
                                .FirstOrDefault();
             return(result);
         }
     }
     catch (Exception ex)
     {
         //logger
         return(null);
     }
 }
예제 #3
0
 public ImageItem[] GetImages()
 {
     try
     {
         using (ImagesDatabaseEntities context = new ImagesDatabaseEntities())
         {
             ImageItem[] result = context.Images
                                  .Select(i => new ImageItem {
                 Id = i.Id, ImageName = i.ImageName, Thumbnail = i.Thumbnail
             })
                                  .ToArray();
             return(result);
         }
     }
     catch (Exception ex)
     {
         //logger
         return(null);
     }
 }
예제 #4
0
 public bool DeleteImage(Guid imageId)
 {
     try
     {
         using (ImagesDatabaseEntities context = new ImagesDatabaseEntities())
         {
             Image image = context.Images.FirstOrDefault(i => i.Id == imageId);
             if (image != null)
             {
                 context.Images.Remove(image);
                 bool result = context.SaveChanges() > 0;
                 return result;
             }
         }
         return true;
     }
     catch (Exception ex)
     {
         //logger
         return false;
     }
 }
예제 #5
0
 public bool DeleteImage(Guid imageId)
 {
     try
     {
         using (ImagesDatabaseEntities context = new ImagesDatabaseEntities())
         {
             Image image = context.Images.FirstOrDefault(i => i.Id == imageId);
             if (image != null)
             {
                 context.Images.Remove(image);
                 bool result = context.SaveChanges() > 0;
                 return(result);
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         //logger
         return(false);
     }
 }
예제 #6
0
 public bool CreateImage(FullImageWithThumbnail image)
 {
     try
     {
         using (ImagesDatabaseEntities context = new ImagesDatabaseEntities())
         {
             Image newImage = new Image
             {
                 Id = Guid.NewGuid()
             };
             UpdateImageWithNewData(newImage, image);
             context.Images.Add(newImage);
             bool result = context.SaveChanges() > 0;
             image.Id = newImage.Id;
             return result;
         }
     }
     catch (Exception ex)
     {
         //logger
         return false;
     }
 }
예제 #7
0
 public bool CreateImage(FullImageWithThumbnail image)
 {
     try
     {
         using (ImagesDatabaseEntities context = new ImagesDatabaseEntities())
         {
             Image newImage = new Image
             {
                 Id = Guid.NewGuid()
             };
             UpdateImageWithNewData(newImage, image);
             context.Images.Add(newImage);
             bool result = context.SaveChanges() > 0;
             image.Id = newImage.Id;
             return(result);
         }
     }
     catch (Exception ex)
     {
         //logger
         return(false);
     }
 }
예제 #8
0
 public FullImage GetImage(Guid imageId)
 {
     try
     {
         using (ImagesDatabaseEntities context = new ImagesDatabaseEntities())
         {
             FullImage result = context.Images.Where(i => i.Id == imageId)
                 .Select(i => new FullImage { Id = i.Id, ImageName = i.ImageName, FullImageData = i.Data })
                 .FirstOrDefault();
             return result;
         }
     }
     catch (Exception ex)
     {
         //logger
         return null;
     }
 }
예제 #9
0
 public bool UpdateImage(FullImageWithThumbnail image)
 {
     try
     {
         using (ImagesDatabaseEntities context = new ImagesDatabaseEntities())
         {
             Image updateImage = context.Images.FirstOrDefault(i => i.Id == image.Id);
             if (updateImage != null)
             {
                 UpdateImageWithNewData(updateImage, image);
                 bool result = context.SaveChanges() > 0;
                 return result;
             }
             else
             {
                 return false;
             }
         }
     }
     catch (Exception ex)
     {
         //logger
         return false;
     }
 }
예제 #10
0
 public ImageItem[] GetImages()
 {
     try
     {
         using (ImagesDatabaseEntities context = new ImagesDatabaseEntities())
         {
             ImageItem[] result = context.Images
                 .Select(i => new ImageItem { Id = i.Id, ImageName = i.ImageName, Thumbnail = i.Thumbnail })
                 .ToArray();
             return result;
         }
     }
     catch (Exception ex)
     {
         //logger
         return null;
     }
 }