public void ThrowsArgumentExceptionWhenElementsToAddAreNotSpecified() { CategoryCollection categoryCollection = new CategoryCollection(); void addRange(IEnumerable <NamedObject> range) => categoryCollection.AddRange("Kursy", range); Assert.ThrowsException <ArgumentNullException>(() => addRange(null)); Assert.ThrowsException <ArgumentException>(() => addRange(Enumerable.Empty <NamedObject>())); }
private async void LoadData() { DepartmentCollection.Clear(); CategoryCollection.Clear(); var dCollection = await DbHandler.Instance.GetAllData <BbDepartment>(); DepartmentCollection.AddRange(dCollection); var cCollection = await DbHandler.Instance.GetAllData <BbCategory>(); CategoryCollection.AddRange(cCollection); }
protected CategoryCollection GetAllCategories(int forParentEntityId) { var result = new CategoryCollection(); var categories = CategoryManager.GetAllCategories(forParentEntityId); foreach (var category in categories) { result.Add(category); result.AddRange(GetAllCategories(category.CategoryId)); } return(result); }
public override async void OnLoad() { base.OnLoad(); List <BbDepartment> deptCollection = await DbHandler.Instance.GetAllData <BbDepartment>(); List <BbCategory> categoryCollection = await DbHandler.Instance.GetAllData <BbCategory>(); DeptCollection.Clear(); CategoryCollection.Clear(); DeptCollection.AddRange(deptCollection); CategoryCollection.AddRange(categoryCollection); }
public ActionResult Save(Bam.Net.Analytics.Category[] values) { try { CategoryCollection saver = new CategoryCollection(); saver.AddRange(values); saver.Save(); return(Json(new { Success = true, Message = "", Dao = "" })); } catch (Exception ex) { return(GetErrorResult(ex)); } }
public void CategoryAndNamedObjectAreSorted() { CategoryCollection categoryCollection = new CategoryCollection(); categoryCollection.AddRange("Kursy", new NamedObject("Python"), new NamedObject("C#"), new NamedObject("Java")) .AddRange("Audiobooki", new NamedObject("HTML"), new NamedObject("CSS"), new NamedObject("JavaScript"), new NamedObject("Angular")); var firstElement = categoryCollection.ElementAt(0); var secondElement = categoryCollection.ElementAt(1); Assert.AreEqual("Audiobooki", firstElement.Key); Assert.AreEqual("HTML", firstElement.Value.ElementAt(2).Name); Assert.AreEqual("Java", secondElement.Value.ElementAt(1).Name); }
private void BindData(CategoryWidget widget) { txtTitle.Text = widget.Title; CategoryCollection cc = new CategoryController().GetTopLevelCachedCategories(); CategoryCollection InUse = new CategoryCollection(); CategoryCollection NotInUse = new CategoryCollection(); NotInUse.AddRange(cc); foreach (int i in widget.CategoryIds) { bool found = false; foreach (Category c in NotInUse) { if (i == c.Id) { InUse.Add(c); found = true; } } if (found) { NotInUse.Remove(InUse[InUse.Count - 1]); } } the_Categories.DataSource = NotInUse; the_Categories.DataBind(); existing_items.Items.Clear(); foreach (Category c in InUse) { existing_items.Items.Add(new OrderedListItem(string.Format(ItemFormat, c.Name, c.Id), c.Name, c.Id.ToString())); } }
private void BindData(CategoryWidget widget) { txtTitle.Text = widget.Title; CategoryCollection cc = new CategoryController().GetTopLevelCachedCategories(); CategoryCollection InUse = new CategoryCollection(); CategoryCollection NotInUse = new CategoryCollection(); NotInUse.AddRange(cc); foreach(int i in widget.CategoryIds) { bool found = false; foreach(Category c in NotInUse) { if(i == c.Id) { InUse.Add(c); found = true; } } if(found) { NotInUse.Remove(InUse[InUse.Count - 1]); } } the_Categories.DataSource = NotInUse; the_Categories.DataBind(); existing_items.Items.Clear(); foreach (Category c in InUse) { existing_items.Items.Add(new Telligent.Glow.OrderedListItem(string.Format(this.ItemFormat, c.Name, c.Id), c.Name, c.Id.ToString())); } }
private static void TestCategoryCollection() { Stopwatch stopwatch = new Stopwatch(); long time1 = stopwatch.TimeMillis(() => { CategoryCollection categoryCollection = new CategoryCollection(); Enumerable.Range(0, 1000000).ForEach(x => categoryCollection.Add("Kategoria", new NamedObject("Nazwa"))); }); long time2 = stopwatch.TimeMillis(() => { CategoryCollection categoryCollection = new CategoryCollection(); var itemsToAdd = Enumerable.Range(0, 1000000).Select(x => new NamedObject("Nazwa")); categoryCollection.AddRange("Kategoria", itemsToAdd); }); ConsoleUtils.WriteResult("Elementy dodane pojedynczo", time1); ConsoleUtils.WriteResult("Elementy dodane wszystkie naraz", time2); }