public List <PhotoListModel> GetAllByAlbumId(Guid albumId) { using (var context = new PhotoLibraryDbContext()) { return(context.Photos.Where(p => p.Album.Id == albumId).Select(mapper.EntityToListModel).ToList()); } }
public List <AlbumListModel> GetAll() { using (var context = new PhotoLibraryDbContext()) { return(context.Albums.Select(mapper.EntityToListModel).ToList()); } }
public List <ItemListModel> GetAllByPhotoId(Guid photoId) { using (var context = new PhotoLibraryDbContext()) { return(context.Items.Where(s => s.Photos.Any(c => c.Id == photoId)).Select(mapper.EntityToListModel).ToList()); } }
public void Database_Exists() { using (var DBContext = new PhotoLibraryDbContext()) { Assert.True(DBContext.Database.Exists()); } }
public PhotoCoordinatesDetailModel GetById(Guid id) { using (var context = new PhotoLibraryDbContext()) { var detailModel = context.PhotoCoordinates.FirstOrDefault(p => p.Id == id); return(mapper.EntityToDetailModel(detailModel)); } }
public AlbumDetailModel GetById(Guid id) { using (var context = new PhotoLibraryDbContext()) { var album = context.Albums.FirstOrDefault(a => a.Id == id); return(mapper.EntityToDetailModel(album)); } }
public PersonDetailModel GetById(Guid id) { using (var context = new PhotoLibraryDbContext()) { var person = context.Persons.FirstOrDefault(a => a.Id == id); return(mapper.EntityToDetailModel(person)); } }
public void Update(PhotoCoordinatesDetailModel coordDetail) { using (var context = new PhotoLibraryDbContext()) { var photoCoord = context.PhotoCoordinates.First(p => p.Id == coordDetail.Id); photoCoord = mapper.DetailModelToEntity(coordDetail); context.SaveChanges(); } }
public List <PhotoCoordinatesDetailModel> GetAllByPhotoId(Guid photoId) { using (var context = new PhotoLibraryDbContext()) { var detailModel = context.PhotoCoordinates.Where(p => p.Photo.Id == photoId) .Select(mapper.EntityToDetailModel).ToList(); return(detailModel); } }
public void Update(ItemDetailModel itemDetail) { using (var context = new PhotoLibraryDbContext()) { var itemEntity = context.Items.First(a => a.Id == itemDetail.Id); itemEntity.Name = itemDetail.Name; context.SaveChanges(); } }
public void Update(PersonDetailModel personDetail) { using (var context = new PhotoLibraryDbContext()) { var personEntity = context.Persons.First(a => a.Id == personDetail.Id); personEntity.FirstName = personDetail.FirstName; personEntity.Surname = personDetail.Surname; context.SaveChanges(); } }
public PhotoCoordinatesDetailModel Insert(PhotoCoordinatesDetailModel coordModel, Guid photoId) { using (var context = new PhotoLibraryDbContext()) { var photoCoord = mapper.DetailModelToEntity(coordModel); photoCoord.Id = Guid.NewGuid(); photoCoord.Photo = context.Photos.First(p => p.Id == photoId); context.PhotoCoordinates.Add(photoCoord); context.SaveChanges(); return(mapper.EntityToDetailModel(photoCoord)); } }
public void Delete(Guid albumId) { using (var context = new PhotoLibraryDbContext()) { var album = context.Albums.First(a => a.Id.Equals(albumId)); if (album != null) { context.Albums.Remove(album); } context.SaveChanges(); } }
public void Update(AlbumDetailModel albumDetail) { using (var context = new PhotoLibraryDbContext()) { var albumEntity = context.Albums.First(a => a.Id == albumDetail.Id); albumEntity.Name = albumDetail.Name; albumEntity.DateTime = albumDetail.DateTime; albumEntity.Description = albumDetail.Description; context.SaveChanges(); } }
public AlbumDetailModel Insert(AlbumDetailModel albumDetail) { using (var context = new PhotoLibraryDbContext()) { var albumEntity = mapper.DetailModelToEntity(albumDetail); albumEntity.Id = Guid.NewGuid(); context.Albums.Add(albumEntity); context.SaveChanges(); return(mapper.EntityToDetailModel(albumEntity)); } }
public PersonDetailModel Insert(PersonDetailModel personDetail, Guid photoId) { using (var context = new PhotoLibraryDbContext()) { var personEntity = mapper.DetailModelToEntity(personDetail); personEntity.Id = Guid.NewGuid(); personEntity.Photos.Add(context.Photos.First(a => a.Id == photoId)); context.Persons.Add(personEntity); context.SaveChanges(); return(mapper.EntityToDetailModel(personEntity)); } }
public PhotoDetailModel Insert(PhotoDetailModel photoDetail, Guid albumId) { using (var context = new PhotoLibraryDbContext()) { var photoEntity = mapper.DetailModelToEntity(photoDetail); photoEntity.Id = Guid.NewGuid(); photoEntity.Album = context.Albums.First(a => a.Id == albumId); context.Photos.Add(photoEntity); context.SaveChanges(); return(mapper.EntityToDetailModel(photoEntity)); } }
public ItemDetailModel Insert(ItemDetailModel itemDetail, Guid photoId) { using (var context = new PhotoLibraryDbContext()) { var itemEntity = mapper.DetailModelToEntity(itemDetail); itemEntity.Id = Guid.NewGuid(); itemEntity.Photos.Add(context.Photos.First(a => a.Id == photoId)); context.Items.Add(itemEntity); context.SaveChanges(); return(mapper.EntityToDetailModel(itemEntity)); } }
public List <CoordinateDetailModel> GetAllByPhotoId(Guid photoId) { using (var context = new PhotoLibraryDbContext()) { var photoCoordinates = context.PhotoCoordinates.Where(p => p.Photo.Id == photoId) .Select(mapper.EntityToDetailModel).ToList(); List <CoordinateDetailModel> result = new List <CoordinateDetailModel>(); foreach (var detailModel in photoCoordinates) { result.InsertRange(0, detailModel.Coordinates); } return(result); } }
public void Delete(Guid personId) { using (var context = new PhotoLibraryDbContext()) { foreach (var person in context.Persons) { if (!person.Id.Equals(personId)) { continue; } context.Persons.Remove(person); break; } context.SaveChanges(); } }
public void Delete(Guid photoId) { using (var context = new PhotoLibraryDbContext()) { foreach (var photo in context.Photos) { if (!photo.Id.Equals(photoId)) { continue; } context.Photos.Remove(photo); break; } context.SaveChanges(); } }
public void Update(PhotoDetailModel photoDetail) { using (var context = new PhotoLibraryDbContext()) { var photoEntity = context.Photos.First(a => a.Id == photoDetail.Id); photoEntity.Name = photoDetail.Name; photoEntity.DateTime = photoDetail.DateTime; photoEntity.FileFormat = photoDetail.FileFormat; photoEntity.Description = photoDetail.Description; photoEntity.Path = photoDetail.Path; photoEntity.Width = photoDetail.Width; photoEntity.Height = photoDetail.Height; context.SaveChanges(); } }
public void Delete(Guid coordId) { using (var context = new PhotoLibraryDbContext()) { foreach (var coord in context.Coordinates) { if (!coord.Id.Equals(coordId)) { continue; } context.Coordinates.Remove(coord); break; } context.SaveChanges(); } }
public void Delete(Guid itemId) { using (var context = new PhotoLibraryDbContext()) { foreach (var item in context.Items) { if (!item.Id.Equals(itemId)) { continue; } context.Items.Remove(item); break; } context.SaveChanges(); } }