public IGroup CreateGroup(string groupName) { // call this constructor doesn't fire the group changed event var createdGroup = new DbGroup(groupName); createdGroup.AssignStores(this.groups, this.dispatcher, this.favorites); return(createdGroup); }
internal void DetachGoup(DbGroup group) { if (group.ParentGroup != null) { this.database.Cache.Detach(group.ParentGroup); } this.Detach(group); }
public void DbGroupNamePropertyValidationTest() { var group = new DbGroup(); group.Name = longText; AssertGroupValidation(group); group.Name = string.Empty; AssertGroupValidation(group); }
internal void AddToGroups(DbGroup toAdd) { toAdd.FieldsToReferences(); if (toAdd.ParentGroup != null) { this.Cache.Attach(toAdd.ParentGroup); } this.Groups.Add(toAdd); }
private void SetChildsToRoot(Database database, DbGroup group) { foreach (var child in this.CachedChilds(group)) { child.Parent = null; database.Cache.Attach(child); this.TrySaveAndReport(child, database); this.cache.Delete(child); } }
private void SaveAndReportUpdated(Database database, DbGroup toUpdate) { database.Cache.MarkAsModified(toUpdate); database.SaveImmediatelyIfRequested(); database.Cache.Detach(toUpdate); this.cache.Update(toUpdate); this.dispatcher.ReportGroupsUpdated(new List <IGroup> { toUpdate }); }
private void TrySaveAndReport(DbGroup toUpdate, Database database) { try { this.SaveAndReportUpdated(database, toUpdate); } catch (DbUpdateException) { this.TryToRefreshUpdated(toUpdate, database); } }
private void TryAdd(IGroup group) { using (Database database = DatabaseConnections.CreateInstance()) { DbGroup toAdd = group as DbGroup; database.AddToGroups(toAdd); database.SaveImmediatelyIfRequested(); database.Cache.DetachGoup(toAdd); this.cache.Add(toAdd); this.dispatcher.ReportGroupsAdded(new List <IGroup> { toAdd }); } }
private void TryToRefreshUpdated(DbGroup toUpdate, Database database) { try { database.RefreshEntity(toUpdate); this.SaveAndReportUpdated(database, toUpdate); } catch (InvalidOperationException) { this.cache.Delete(toUpdate); this.dispatcher.ReportGroupsDeleted(new List <IGroup> { toUpdate }); } }
public void DbGroupValidationTest() { var group = new DbGroup(); group.Name = longText; var results = Validations.Validate(group); Assert.AreEqual(1, results.Count, "Group name validation failed"); }
private void SetChildsToRoot(Database database, DbGroup group) { foreach (DbGroup child in this.CachedChilds(group)) { child.Parent = null; database.Cache.Attach(child); this.TrySaveAndReport(child, database); this.cache.Delete(child); } }
private static void AssertGroupValidation(DbGroup group) { ValidationStates results = Validations.ValidateNameProperty(group); Assert.AreEqual(1, results.Count(), "Group name validation failed"); Assert.AreEqual(Validations.NAME_PROPERTY, results.First().PropertyName, "Failed property is not a 'Name'"); }
internal void LoadFieldsFromReferences() { // loaded at once, so we expect to have the parent group instance also in cache this.parent = this.ParentGroup; }
private void TryToRefreshUpdated(DbGroup toUpdate, Database database) { try { database.RefreshEntity(toUpdate); this.SaveAndReportUpdated(database, toUpdate); } catch (InvalidOperationException) { this.cache.Delete(toUpdate); this.dispatcher.ReportGroupsDeleted(new List<IGroup>(){ toUpdate }); } }
internal void Attach(DbGroup group) { group.FieldsToReferences(); this.database.Groups.Attach(group); }
private void SaveAndReportUpdated(Database database, DbGroup toUpdate) { database.Cache.MarkAsModified(toUpdate); database.SaveImmediatelyIfRequested(); database.Cache.Detach(toUpdate); this.cache.Update(toUpdate); this.dispatcher.ReportGroupsUpdated(new List<IGroup>() { toUpdate }); }