Exemple #1
0
        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);
        }
Exemple #2
0
 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);
 }
Exemple #4
0
 internal void AddToGroups(DbGroup toAdd)
 {
     toAdd.FieldsToReferences();
     if (toAdd.ParentGroup != null)
     {
         this.Cache.Attach(toAdd.ParentGroup);
     }
     this.Groups.Add(toAdd);
 }
Exemple #5
0
 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);
     }
 }
Exemple #6
0
 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
     });
 }
Exemple #7
0
 private void TrySaveAndReport(DbGroup toUpdate, Database database)
 {
     try
     {
         this.SaveAndReportUpdated(database, toUpdate);
     }
     catch (DbUpdateException)
     {
         this.TryToRefreshUpdated(toUpdate, database);
     }
 }
Exemple #8
0
 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
         });
     }
 }
Exemple #9
0
 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'");
 }
Exemple #13
0
 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 });
     }
 }
 private void TrySaveAndReport(DbGroup toUpdate, Database database)
 {
     try
     {
         this.SaveAndReportUpdated(database, toUpdate);
     }
     catch (DbUpdateException)
     {
         this.TryToRefreshUpdated(toUpdate, database);
     }
 }
Exemple #16
0
 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 });
 }