private AssetApiModel AssetApiModel(ScheduledImage im)
 {
     return new AssetApiModel()
     {
         FileName = im.FileName,
         Url = im.DownloadUrl
     };
 }
        public async Task PostHttpNotificationAsync(ScheduledImage scheduledImage)
        {
            var httpClient = new HttpClient();
            var result     = await httpClient.PostAsJsonAsync(scheduledImage.SuccessNotificationUrl, new
            {
                FileName = scheduledImage.FileName,
                Metadata = scheduledImage.MetadataTags.Select(c => new { TagName = c.Name, Value = c.MetadataValue })
            });

            if (!result.IsSuccessStatusCode)
            {
                var resultContent = await result.Content.ReadAsStringAsync();

                throw new Exception($"Request was not successful. Got error response. \n {resultContent}");
            }
        }
 private void ScheduleBackgroundJob(ScheduledImage imageMetadata)
 {
     var helper = new JobsHelper(_context, new DownloadToStream(), new CustomMetadataReader(), _backgroundJobClient, _postNotificationSender);
     _backgroundJobClient.Enqueue(() => helper.DownloadAndReadMetadata(imageMetadata.Id));
 }
        private ScheduledImage SaveScheduleImageEndity(AssetApiModel assetApiModel)
        {
            var imageMetadata = new ScheduledImage()
            {
                FileName = assetApiModel.FileName,
                DownloadUrl = assetApiModel.Url,
                SuccessNotificationUrl = assetApiModel.SuccessNotificationUrl,
                CreatedDate = DateTime.UtcNow
            };
            _context.ScheduledImages.Add(imageMetadata);

            _context.SaveChanges();
            return imageMetadata;
        }