public DiscordEmbed Build(CachedFlickrPhoto photo)
        {
            var date = photo.UploadDate.ToString("F", CultureInfo.InvariantCulture);

            return(new DiscordEmbedBuilder
            {
                Title = $"{photo.Title}",
                Url = $"https://www.flickr.com/photos/spacex/{photo.Id}",
                Color = new DiscordColor(Constants.EmbedColor),
                ImageUrl = photo.Source,
                Footer = new DiscordEmbedBuilder.EmbedFooter
                {
                    Text = $"{date} UTC"
                }
            });
        }
Beispiel #2
0
        private async Task <List <CachedFlickrPhoto> > AddPhotosToDatabaseAsync(List <FlickrPhoto> photos)
        {
            var cachedPhotos = new List <CachedFlickrPhoto>();

            using (var databaseContext = new DatabaseContext())
            {
                foreach (var photo in photos)
                {
                    var source = await GetImageUrlAsync(photo.Id);

                    var date = await GetImageUploadDateAsync(photo.Id);

                    var cachedPhoto = new CachedFlickrPhoto(photo, date, source);

                    await databaseContext.CachedFlickrPhotos.AddAsync(cachedPhoto);

                    cachedPhotos.Add(cachedPhoto);
                }

                await databaseContext.SaveChangesAsync();
            }

            return(cachedPhotos);
        }