private static (Season season, Year year) GetSeasonInformation(string nodeValue) { var parts = nodeValue.Split(' '); var season = Season.FromString(parts[0]); var result = int.TryParse(parts[1], out int year); if (!result) { throw new ArgumentException("Year couldn't be extracted"); } return(season, new Year(year)); }
public static void Run( [BlobTrigger("images-process/{name}", Connection = "AzureWebJobsStorage")] string contents, string name, [Queue(QueueNames.ImageProcess)] IAsyncCollector <BlobImageInfo> queueCollector, ILogger log) { var deserializeImageProcess = JsonConvert.DeserializeObject <ImageProcessInfo>(contents); if (deserializeImageProcess?.SeasonInfo == null || string.IsNullOrEmpty(deserializeImageProcess.SeasonInfo.Season)) { return; } var season = Season.FromString(deserializeImageProcess.SeasonInfo.Season); var data = deserializeImageProcess.ImagesInfo .Where(x => !string.IsNullOrEmpty(x.Title) && !string.IsNullOrEmpty(x.Url)) .Select(x => CreateDomainInformation(x, season, deserializeImageProcess.SeasonInfo.Year)) .ToImmutableList(); QueueStorage.StoreInQueue(data, queueCollector, log, blobInfo => $"New image '{blobInfo.BlobName}' has been enqueue for upload. Source {blobInfo.RemoteUrl}"); }
internal static SeasonInformation Project(SeasonStorage seasonStorage) { return(new SeasonInformation(Season.FromString(seasonStorage.Season), new Year(seasonStorage.Year))); }