예제 #1
0
        private void GroupsTree_DragDrop(object o, DragDropArgs args)
        {
            Drag.Finish(args.Context, true, true, args.Time);
            if (grid.Selection.Count == 0)
            {
                return;
            }

            TreePath             path;
            TreeViewDropPosition pos;

            groupsPanel.GroupsTree.GetDestRowAtPos(args.X, args.Y, out path, out pos);

            TreeIter row;

            groupsPanel.GroupsTree.Model.GetIter(out row, path);
            G group = (G)groupsPanel.GroupsTree.Model.GetValue(row, 2);

            using (Message messageDialog = GetMovingToGroupMessage(group.Name)) {
                messageDialog.Buttons = MessageButtons.YesNo;
                if (messageDialog.Run() != ResponseType.Yes)
                {
                    return;
                }

                foreach (int selectedIndex in grid.Selection)
                {
                    object entity = grid.Model [selectedIndex];
                    IPersistableEntity <T> persistableEntity = entity as IPersistableEntity <T>;
                    if (persistableEntity == null)
                    {
                        continue;
                    }

                    IHirarchicalEntity hirarchicalEntity = entity as IHirarchicalEntity;
                    if (hirarchicalEntity == null)
                    {
                        continue;
                    }

                    if (group.Id == GroupBase <G> .DeletedGroupId)
                    {
                        hirarchicalEntity.Deleted = true;
                        hirarchicalEntity.GroupId = GroupBase <G> .DefaultGroupId;
                    }
                    else
                    {
                        hirarchicalEntity.Deleted = false;
                        hirarchicalEntity.GroupId = group.Id;
                    }
                    persistableEntity.CommitChanges();
                }
                OnEntitiesChanged(groupsPanel.GetSelectedGroupId());
                OnEntitiesMovedToAGroup();
            }
        }
예제 #2
0
        public Task Save(IPersistableEntity dataToSave)
        {
            if (!_dataToStore.ContainsKey(dataToSave.PersistenceId))
            {
                _dataToStore.Add(dataToSave.PersistenceId, new List <IPersistableEntity>());
            }

            _dataToStore[dataToSave.PersistenceId].Add(dataToSave);

            return(Task.FromResult(true));
        }
 public Task Save(IPersistableEntity dataToSave)
 {
     Log("Saving single ", dataToSave);
     try
     {
         return(persistableEntityRepository.Save(dataToSave));
     }
     catch (Exception e)
     {
         Log("couldn't save", e);
         throw;
     }
 }