コード例 #1
0
        private IEnumerable <CollectionItemImage> ToCollectionItemImages(IEnumerable <ImageDto> images, IServiceLocator locator)
        {
            var domainEntities = new List <CollectionItemImage>();

            foreach (var image in images)
            {
                var itemImage = new CollectionItemImage();
                locator.Get <AssemblerBase <CollectionItemImage, ImageDto> >().FillDomainEntity(itemImage, image);
                domainEntities.Add(itemImage);
            }
            return(domainEntities);
        }
コード例 #2
0
        public void FillEntity()
        {
            var poco = new CollectionItemImage();

            poco.Id               = Guid.NewGuid();
            poco.DateAdded        = new DateTime(2015, 1, 2);
            poco.Description      = "desc";
            poco.CollectionItemId = Guid.NewGuid();
            var entity = new tblCollectionItemImage();

            _translator.FillDataEntity(entity, poco);

            Assert.AreEqual(entity.Id, poco.Id);
            Assert.AreEqual(entity.tblCollectionItemId, poco.CollectionItemId);
            Assert.AreEqual(entity.DateAdded, new DateTime(2015, 1, 2));
            Assert.AreEqual(entity.Description, "desc");
        }
コード例 #3
0
        public void SaveImageGallery(ImageGalleryDto imageGallery)
        {
            var images    = new List <CollectionItemImage>(imageGallery.Images.Count);
            var originals = _repository.GetByCollectionItemId(imageGallery.CollectionItemId);

            foreach (var img in imageGallery.Images)
            {
                var poco = new CollectionItemImage();
                _assembler.FillDomainEntity(poco, img);
                images.Add(poco);
            }

            var merger = new DelegateMerger <CollectionItemImage>(
                e => { AddImage(e, imageGallery.Images.Single(x => x.Id == e.Id)); },
                e => { _publisher.Update(e); },
                DeleteImage
                );

            merger.Merge(originals, images);
            _unitOfWork.SaveChanges();
        }
コード例 #4
0
        public void Update(CollectionItemImage collectionItemImage)
        {
            var entity = _context.tblCollectionItemImage.Find(collectionItemImage.Id);

            _translator.FillDataEntity(entity, collectionItemImage);
        }
コード例 #5
0
        public void Add(CollectionItemImage collectionItemImage)
        {
            var entity = _translator.ToDataEntity(collectionItemImage);

            _context.tblCollectionItemImage.Add(entity);
        }
コード例 #6
0
 private void DeleteImage(CollectionItemImage collectionItemImage)
 {
     _terminator.Terminate(collectionItemImage.Id);
     _repository.DeleteFullImage(collectionItemImage.Id);
 }
コード例 #7
0
 private void AddImage(CollectionItemImage collectionItemImage, ImageDto dto)
 {
     _publisher.Add(collectionItemImage);
     _repository.AddFullImage(dto.Id, File.ReadAllBytes(dto.ImagePath));
 }