示例#1
0
    void SelectById (TModelContext context, TEntityAction action)
    {
      /*
      DATA IN
      - action.Id 
      - action.CollectionAction.CategoryRelationCollection

      DATA OUT
      - action.ModelAction (model)
      - action.CollectionAction.ModeCollection {id, model} (for each node)
      - action.CollectionAction.EntityCollection {id, model} (for each relation)
      */

      try {
        // Id must exist
        if (action.Id.IsEmpty ()) {
          action.Result = new TValidationResult ("[Select ById] Id can NOT be NULL or EMPTY!");
        }

        else {
          action.Result = TValidationResult.Success; // desired result DO NOT MOVE FROM HERE

          // relation by id (use parent)
          action.CollectionAction.SelectComponentOperation (TComponentOperation.TInternalOperation.Id);
          action.ComponentOperation.SelectById (action.Id);

          var operationSupport = new TOperationSupport (context, action);
          operationSupport.RequestComponent (context, action);
          operationSupport.RequestExtension (context, action);
          TOperationSupport.RequestNode (context, action);
          TOperationSupport.RequestRelation (context, action);

          // use Parent relation
          if (action.ComponentOperation.ParentIdCollection.ContainsKey (action.Id)) {
            var componentRelationList = action.ComponentOperation.ParentIdCollection [action.Id];

            foreach (var relation in componentRelationList) {
              var entityAction = TEntityAction.Create (TCategoryType.FromValue (relation.ChildCategory));
              entityAction.CollectionAction.SetCollection (action.CollectionAction.CategoryRelationCollection);
              entityAction.Id = relation.ChildId;

              SelectById (context, entityAction); // my self (tree navigation)

              action.CollectionAction.EntityCollection.Add (relation.ChildId, entityAction);
            }
          }
        }
      }

      catch (Exception exception) {
        Server.Models.Infrastructure.THelper.FormatException ("Select ById", exception, action);
      }
    }
示例#2
0
    void SelectRelation (TModelContext context, TEntityAction action)
    {
      /*
       DATA IN
      - action.ComponentOperation 

      DATA OUT
      - action.ComponentOperation
      */

      try {
        var operationSupport = new TOperationSupport (context, action);
        TOperationSupport.RequestRelation (context, action);

        action.Result = TValidationResult.Success;
      }

      catch (Exception exception) {
        Server.Models.Infrastructure.THelper.FormatException ("Select Relation", exception, action);
      }
    }
示例#3
0
    void SelectNode (TModelContext context, TEntityAction action)
    {
      /*
      DATA IN
      - action.CollectionAction.CategoryRelationCollection
      - action.ComponentModel (NodeModelCollection)

      DATA OUT
      - action.CollectionAction.ModelCollection {id, model}

      */

      try {
        TOperationSupport.RequestNode (context, action);

        action.Result = TValidationResult.Success;
      }

      catch (Exception exception) {
        Server.Models.Infrastructure.THelper.FormatException ("Select Node", exception, action);
      }
    }