public async Task <IEnumerable <Image> > Adicionar(ImageModel model) { var listImages = new List <Image>(); if (model.Images == null) { return(listImages); } foreach (var image in model.Images) { var customFileName = CreateCustomFileName(image); string path = Path.Combine(GeneralHelpers.CreateIfNotExistsImagePathAndReturn(), customFileName); var newImage = new Image(customFileName, model.Orphanage.Id, model.Orphanage); if (!newImage.IsValid()) { throw new InvalidOperationException(newImage.ErrorMessages.FirstOrDefault()); } await AdicionarImagemNaPasta(image, path); listImages.Add(newImage); } await _repository.Adicionar(listImages); return(listImages); }
public async Task <string> ObterPorId(Guid id) { var images = await _repository.ObterPorId(id); if (images == null) { return(null); } string filePath = Path.Combine(GeneralHelpers.CreateIfNotExistsImagePathAndReturn(), images.Path); return(filePath); }