Пример #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 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;
     }
 }
Пример #3
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);
     }
 }
Пример #4
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;
     }
 }
Пример #5
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);
     }
 }
Пример #6
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;
     }
 }