コード例 #1
0
ファイル: Factory.cs プロジェクト: gbachs/Terminals
        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);
        }
コード例 #2
0
 internal void DetachGoup(DbGroup group)
 {
     if (group.ParentGroup != null)
     {
         this.database.Cache.Detach(group.ParentGroup);
     }
     this.Detach(group);
 }
コード例 #3
0
 public void DbGroupNamePropertyValidationTest()
 {
     var group = new DbGroup();
     group.Name = longText;
     AssertGroupValidation(group);
     group.Name = string.Empty;
     AssertGroupValidation(group);
 }
コード例 #4
0
 internal void AddToGroups(DbGroup toAdd)
 {
     toAdd.FieldsToReferences();
     if (toAdd.ParentGroup != null)
     {
         this.Cache.Attach(toAdd.ParentGroup);
     }
     this.Groups.Add(toAdd);
 }
コード例 #5
0
ファイル: GroupsLogic.cs プロジェクト: gbachs/Terminals
 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);
     }
 }
コード例 #6
0
ファイル: GroupsLogic.cs プロジェクト: gbachs/Terminals
 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
     });
 }
コード例 #7
0
ファイル: GroupsLogic.cs プロジェクト: gbachs/Terminals
 private void TrySaveAndReport(DbGroup toUpdate, Database database)
 {
     try
     {
         this.SaveAndReportUpdated(database, toUpdate);
     }
     catch (DbUpdateException)
     {
         this.TryToRefreshUpdated(toUpdate, database);
     }
 }
コード例 #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
         });
     }
 }
コード例 #9
0
ファイル: GroupsLogic.cs プロジェクト: gbachs/Terminals
 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
         });
     }
 }
コード例 #10
0
 public void DbGroupValidationTest()
 {
     var group = new DbGroup();
     group.Name = longText;
     var results = Validations.Validate(group);
     Assert.AreEqual(1, results.Count, "Group name validation failed");
 }
コード例 #11
0
 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);
     }
 }
コード例 #12
0
 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'");
 }
コード例 #13
0
ファイル: GroupLogic.cs プロジェクト: zivalin/Terminals
 internal void LoadFieldsFromReferences()
 {
     // loaded at once, so we expect to have the parent group instance also in cache
     this.parent = this.ParentGroup;
 }
コード例 #14
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 });
     }
 }
コード例 #15
0
 private void TrySaveAndReport(DbGroup toUpdate, Database database)
 {
     try
     {
         this.SaveAndReportUpdated(database, toUpdate);
     }
     catch (DbUpdateException)
     {
         this.TryToRefreshUpdated(toUpdate, database);
     }
 }
コード例 #16
0
 internal void Attach(DbGroup group)
 {
     group.FieldsToReferences();
     this.database.Groups.Attach(group);
 }
コード例 #17
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 });
 }