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); }
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"); }
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(); }
public void Update(CollectionItemImage collectionItemImage) { var entity = _context.tblCollectionItemImage.Find(collectionItemImage.Id); _translator.FillDataEntity(entity, collectionItemImage); }
public void Add(CollectionItemImage collectionItemImage) { var entity = _translator.ToDataEntity(collectionItemImage); _context.tblCollectionItemImage.Add(entity); }
private void DeleteImage(CollectionItemImage collectionItemImage) { _terminator.Terminate(collectionItemImage.Id); _repository.DeleteFullImage(collectionItemImage.Id); }
private void AddImage(CollectionItemImage collectionItemImage, ImageDto dto) { _publisher.Add(collectionItemImage); _repository.AddFullImage(dto.Id, File.ReadAllBytes(dto.ImagePath)); }