Exemplo n.º 1
0
        private void EditInternal <TProperty>(TEntity Entity, EditedEntity <TEntity, TProperty> Edited, ForeignStatus ForeignStatus)
        {
            Entity.State = Entity.State.BeginEdit();

            if (Edited.EntityRelationForeignManager == null)
            {
                Entity.Data.Set(Edited.Property, Edited.Value.New);

                if (Edited.TrakMode.IsTrack())
                {
                    EntityChangeTracker.Track(Entity, Edited.Property);
                }
                else if (Edited.TrakMode.IsUnTrack())
                {
                    EntityChangeTracker.UnTrack(Entity, Edited.Property);
                }

                Entity.OnPropertyChanged(Edited.Property.Name);
            }
            else
            {
                Edited.EntityRelationForeignManager.UpdateOnEdit(Entity, Edited, ForeignStatus);
            }

            Entity.State = Entity.State.EndEdit();

            EditInternalNotifyAllRelated(Entity);
        }
Exemplo n.º 2
0
        internal void CallBack <TProperty>(TEntity Entity, EditedEntity <TEntity, TProperty> Edited)
        {
            IEntityRelationForeignManager <TEntity> EntityRelationForeignManager = entityRelationForeignManagers[GetEntityRelation(Edited.Property)];

            ForeignStatus foreignStatus = EntityRelationForeignManager.GetForeignStatus(Entity, Edited);

            EntityRelationForeignManager.UpdateOnEdit(Entity, Edited, foreignStatus);
        }
Exemplo n.º 3
0
        internal void Edit <TProperty>(TEntity Entity, EditedEntity <TEntity, TProperty> Edited)
        {
            EntityRelation relation = GetEntityRelation(Edited.Property);

            Edited.EntityRelationForeignManager = relation == null ? null : entityRelationForeignManagers[relation];

            EditImp(Entity, Edited);
        }
Exemplo n.º 4
0
        private void CanEditForeign <TProperty>(TEntity Entity, EditedEntity <TEntity, TProperty> Edited, out ForeignStatus ForeignStatus)
        {
            ForeignStatus = GetForeignStatus(Entity, Edited);

            if (!ForeignStatus.IsValid())
            {
                throw new EntitySetCanEditException($"{Entity} Property {Edited.Property.Name} {ForeignStatus}");
            }
        }
Exemplo n.º 5
0
        private void CanEdit <TProperty>(TEntity Entity, EditedEntity <TEntity, TProperty> Edited, out ForeignStatus ForeignStatus)
        {
            if (!typeof(TEntity).Contains(Edited.Property))
            {
                throw new CriticalException($"{Entity.GetType()} Not Contains Property {Edited.Property.Name}");
            }

            if (Edited.Property == Key)
            {
                throw new EntitySetEditException($"Can't Edit Key Property, {Entity.GetType()}.{Edited.Property.Name}");
            }

            ForeignStatus = ForeignStatus.Unkhown;

            if (Edited.EntityRelationForeignManager != null)
            {
                CanEditForeign(Entity, Edited, out ForeignStatus);
            }
        }
Exemplo n.º 6
0
 private ForeignStatus GetForeignStatus <TProperty>(TEntity Entity, EditedEntity <TEntity, TProperty> Edited)
 {
     return(Edited.EntityRelationForeignManager.GetForeignStatus(Entity, Edited));
 }
Exemplo n.º 7
0
        private void EditImp <TProperty>(TEntity Entity, EditedEntity <TEntity, TProperty> Edited)
        {
            CanEdit(Entity, Edited, out ForeignStatus ForeignStatus);

            EditInternal(Entity, Edited, ForeignStatus);
        }