Exemple #1
0
        //[ResponseCache(Location = ResponseCacheLocation.Any, Duration = int.MaxValue, VaryByHeader = "Cookie", VaryByQueryKeys = new[] { "accountId", "itemId" })]
        public async Task <IActionResult> FeaturedImage(Guid accountId, Guid itemId)
        {
            var account = DataRepository.Get <Account>(accountId);
            var item    = new KeyValuePair <int, WishlistItem>();

            foreach (var year in account.Wishlist.Keys)
            {
                var match = account.Wishlist[year].FirstOrDefault(x => x.Id == itemId);
                if (match != null)
                {
                    item = new KeyValuePair <int, WishlistItem>(year, match);
                    break;
                }
            }

            if (item.Value.PreviewImage == null || item.Value.PreviewImage.Length == 0)
            {
                account.Wishlist[item.Key].Remove(item.Value);
                item.Value.PreviewImage = await PreviewGenerator.GetFeaturedImage(item.Value.Url);

                account.Wishlist[item.Key].Add(item.Value);
                DataRepository.Save(account);
            }

            return(File(item.Value.PreviewImage, "image/jpg"));
        }
Exemple #2
0
        public static async void EditItem(Account account, WishlistItem item)
        {
            WishlistItem remove = account.Wishlist[DateHelper.Year].SingleOrDefault(i => i.Id.Equals(item.Id));

            account.Wishlist[DateHelper.Year].Remove(remove);
            item.PreviewImage = await PreviewGenerator.GetFeaturedImage(item.Url);

            account.Wishlist[DateHelper.Year].Add(item);
            DataRepository.Save(account);
        }
Exemple #3
0
        public static async void AddItem(Account account, WishlistItem item)
        {
            if (!account.Wishlist.ContainsKey(DateHelper.Year))
            {
                account.Wishlist.Add(DateHelper.Year, new List <WishlistItem>());
            }
            item.Id           = Guid.NewGuid();
            item.PreviewImage = await PreviewGenerator.GetFeaturedImage(item.Url);

            account.Wishlist[DateHelper.Year].Add(item);
            DataRepository.Save(account);
        }