Esempio n. 1
0
        protected async override Task ApplyModifiersAsync(WalletCategory walletCategory, WalletCategoryModifier modifier)
        {
            if (modifier.IncludeWallet || modifier.IncludeAll)
            {
                walletCategory.Wallet = await wallets.GetAsync(walletCategory.WalletId, new WalletModifier()
                {
                    IncludeImage = true
                });
            }

            if (modifier.IncludeCategory)
            {
                walletCategory.Category = await categories.GetAsync(walletCategory.CategoryId, new CategoryModifier()
                {
                    IncludeImage = true
                });
            }
            else if (modifier.IncludeWholeCategory || modifier.IncludeAll)
            {
                walletCategory.Category = await categories.GetAsync(walletCategory.CategoryId, new CategoryModifier()
                {
                    IncludeImage = true, IncludeRules = true
                });
            }
        }
Esempio n. 2
0
        public async Task CategoryCRUDTest()
        {
            await categories.DeleteAllAsync();

            var cat1 = new Category()
            {
                Name = "Category 1"
            };
            var cat2 = new Category()
            {
                Name = "Category 2"
            };

            await categories.InsertAsync(cat1, cat2);

            var cats = await categories.GetAllAsync();

            Assert.AreEqual(2, cats.Count);

            var category1Id = cats.Where(x => x.Name == "Category 1").Single().Id;
            var category2Id = cats.Where(x => x.Name == "Category 2").Single().Id;

            var filter = new CategoryFilter()
            {
                Name = "Category 1"
            };

            Assert.AreEqual("Category 1", (await categories.GetAsync(filter)).Single().Name);
            Assert.AreEqual("Category 1", (await categories.GetAsync(category1Id)).Name);

            filter.Name = "Category 2";
            Assert.AreEqual("Category 2", (await categories.GetAsync(filter)).Single().Name);
            Assert.AreEqual("Category 2", (await categories.GetAsync(category2Id)).Name);

            filter.Name = "Category";
            Assert.AreEqual(2, (await categories.GetAsync(filter)).Count);

            await categories.UpdateAsync(new Category()
            {
                Id = category1Id, Name = "Updated Category"
            });

            Assert.AreEqual(2, (await categories.GetAllAsync()).Count);

            filter.Name = "Category 1";
            Assert.AreEqual(0, (await categories.GetAsync(filter)).Count);
            Assert.AreEqual("Updated Category", (await categories.GetAsync(category1Id)).Name);

            await categories.DeleteAsync(category2Id);

            Assert.AreEqual(1, (await categories.GetAllAsync()).Count);

            await categories.DeleteAllAsync();

            Assert.AreEqual(0, (await categories.GetAllAsync()).Count);
        }
Esempio n. 3
0
 protected async override Task ApplyModifiersAsync(Rule rule, RuleModifier modifier)
 {
     if (modifier.IncludeCategory || modifier.IncludeAll)
     {
         rule.Category = await categories.GetAsync(rule.CategoryId);
     }
 }
Esempio n. 4
0
 public Task <IEnumerable <CategoryListItemDto> > GetCategoriesAsync()
 {
     return(Categories.GetAsync());
 }