public Category FindCategory(string name) { if (Name.ToLower() == name.ToLower()) { return(this); } else { return(SubCategories.Select(subCategory => subCategory.FindCategory(name)).FirstOrDefault(sub => sub != null)); } }
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); }
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); }
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); } }