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); } }
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; } }
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); } }
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; } }
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); } }
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; } }