public Ad(Infrastructure.Entities.Ad infrastructureAd, IEnumerable <Infrastructure.Entities.Picture> infrastructurePictures) { Id = infrastructureAd.Id; Description = infrastructureAd.Description; GardenSize = infrastructureAd.GardenSize; HouseSize = infrastructureAd.HouseSize; if (Enum.TryParse(infrastructureAd.Typology, out Typology typology)) { Typology = typology; } Pictures = GetPicturesByInfrastructurePictures(GetInfrastructurePictures(infrastructureAd, infrastructurePictures)); }
private static IEnumerable <Infrastructure.Entities.Picture> GetInfrastructurePictures(Infrastructure.Entities.Ad infrastructureAd, IEnumerable <Infrastructure.Entities.Picture> infrastructurePictures) { return(infrastructurePictures.Where(x => infrastructureAd.Pictures.Contains(x.Id))); }