Example #1
0
        public ICommand Execute(ICommand command)
        {
            foreach (var key in command.getOptions().Keys)
            {
                command.getOptions().TryGetValue(key, out string value);
                command.AddLine($"{key}={value}");
            }
            // - need: entity type, key, other properties (as JSON?)
            // Entity instance from entityID
            command.getOptions().TryGetValue(ModelKeyAdd.p_entity, out string entityID);
            var baseModelKey = ModelUtils.NewEntityInstance(entityID);

            if (baseModelKey == null)
            {
                // exit command, user input invalid
                command.Abort($"Unknown entityID: {entityID}");
                return(command);
            }
            // Set entity key
            command.getOptions().TryGetValue(ModelKeyAdd.p_entity_key, out string entityKey);
            baseModelKey.Key = entityKey;
            // @TODO_GUN: Set other properties
            // Persist: get persistence services and persist it
            ServicesProviderBridge._modelKeyDAODict.TryGetValue(baseModelKey.GetType(), out IModelKeyDAO modelKeyDAO);
            modelKeyDAO.Add(baseModelKey);
            return(command);
        }