Exemplo n.º 1
0
 public Category FindCategory(string name)
 {
     if (Name.ToLower() == name.ToLower())
     {
         return(this);
     }
     else
     {
         return(SubCategories.Select(subCategory => subCategory.FindCategory(name)).FirstOrDefault(sub => sub != null));
     }
 }
Exemplo n.º 2
0
        private static async Task InsertTestData(IServiceProvider serviceProvider)
        {
            var publishers    = Publishers;
            var categories    = Categories;
            var subCategories = SubCategories;

            var products = GetProducts();

            await AddOrUpdateAsync(serviceProvider, p => p.Id, Publishers.Select(publisher => publisher.Value));
            await AddOrUpdateAsync(serviceProvider, c => c.Id, Categories.Select(category => category.Value));
            await AddOrUpdateAsync(serviceProvider, sc => sc.Id, SubCategories.Select(subCategory => subCategory.Value));
            await AddOrUpdateAsync(serviceProvider, p => p.Id, products);
        }
Exemplo n.º 3
0
        public CategoryEntity MapToEntity()
        {
            var entity = new CategoryEntity
            {
                Id            = Id,
                Balance       = Balance,
                Currency      = Currency,
                Name          = Name,
                PlannedAmount = PlannedAmount,
                SubCategories = SubCategories?.Select(x => x.MapToEntity())
            };

            return(entity);
        }
Exemplo n.º 4
0
        public void InsertSubCategory(NodeCategoryViewModel newSubCategory)
        {
            var first = SubCategories.Select((x, i) => new { x.Name, Idx = i })
                        .FirstOrDefault(
                x =>
                string.Compare(
                    x.Name,
                    newSubCategory.Name,
                    StringComparison.Ordinal)
                >= 0);

            if (first != null)
            {
                SubCategories.Insert(first.Idx, newSubCategory);
            }
            else
            {
                SubCategories.Add(newSubCategory);
            }
        }