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