/// <summary>
        /// Creates and shows a document that contains a single object view model for the existing entity.
        /// Since CollectionViewModelBase is a POCO view model, an the instance of this class will also expose the EditCommand property that can be used as a binding source in views.
        /// </summary>
        /// <param name="projectionEntity">Entity to edit.</param>
        public virtual void Edit(TProjection projectionEntity)
        {
            if (Repository.IsDetached(projectionEntity))
            {
                return;
            }
            TPrimaryKey primaryKey = Repository.GetProjectionPrimaryKey(projectionEntity);
            int         index      = Entities.IndexOf(projectionEntity);

            projectionEntity = ChangeTrackerWithKey.FindActualProjectionByKey(primaryKey);
            if (index >= 0)
            {
                if (projectionEntity == null)
                {
                    Entities.RemoveAt(index);
                }
                else
                {
                    Entities[index] = projectionEntity;
                }
            }
            if (projectionEntity == null)
            {
                DestroyDocument(DocumentManagerService.FindEntityDocument <TEntity, TPrimaryKey>(primaryKey));
                return;
            }
            DocumentManagerService.ShowExistingEntityDocument <TEntity, TPrimaryKey>(this, primaryKey);
        }
Exemple #2
0
        public virtual void Edit(object threadSafeProxy)
        {
            if (!source.IsLoadedProxy(threadSafeProxy))
            {
                return;
            }
            TPrimaryKey primaryKey = GetProxyPrimaryKey(threadSafeProxy);
            TEntity     entity     = helperRepository.Find(primaryKey);

            if (entity == null)
            {
                DestroyDocument(DocumentManagerService.FindEntityDocument <TEntity, TPrimaryKey>(primaryKey));
                return;
            }
            DocumentManagerService.ShowExistingEntityDocument <TEntity, TPrimaryKey>(this, primaryKey);
        }