Ejemplo n.º 1
0
 public List <PhotoListModel> GetAllByAlbumId(Guid albumId)
 {
     using (var context = new PhotoLibraryDbContext())
     {
         return(context.Photos.Where(p => p.Album.Id == albumId).Select(mapper.EntityToListModel).ToList());
     }
 }
Ejemplo n.º 2
0
 public List <AlbumListModel> GetAll()
 {
     using (var context = new PhotoLibraryDbContext())
     {
         return(context.Albums.Select(mapper.EntityToListModel).ToList());
     }
 }
Ejemplo n.º 3
0
 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());
     }
 }
Ejemplo n.º 4
0
 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));
     }
 }
Ejemplo n.º 6
0
        public AlbumDetailModel GetById(Guid id)
        {
            using (var context = new PhotoLibraryDbContext())
            {
                var album = context.Albums.FirstOrDefault(a => a.Id == id);

                return(mapper.EntityToDetailModel(album));
            }
        }
Ejemplo n.º 7
0
        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);
            }
        }
Ejemplo n.º 10
0
        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();
            }
        }
Ejemplo n.º 11
0
        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));
            }
        }
Ejemplo n.º 13
0
        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();
            }
        }
Ejemplo n.º 14
0
        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();
            }
        }
Ejemplo n.º 15
0
        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));
            }
        }
Ejemplo n.º 16
0
        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));
            }
        }
Ejemplo n.º 17
0
        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));
            }
        }
Ejemplo n.º 18
0
        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));
            }
        }
Ejemplo n.º 19
0
        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);
            }
        }
Ejemplo n.º 20
0
        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();
            }
        }
Ejemplo n.º 21
0
        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();
            }
        }
Ejemplo n.º 22
0
        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();
            }
        }
Ejemplo n.º 23
0
        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();
            }
        }
Ejemplo n.º 24
0
        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();
            }
        }