示例#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;
     }
 }