Ejemplo n.º 1
0
        public WebHookSession ToRepositoryType(IRepositoryModelCache cache, IComputerRepository computerRepository)
        {
            var result = new WebHookSession(
                computer: ComputerModel.ToRepositoryType(cache, Computer_Id, computerRepository),
                id: Id,
                lastPing: LastPing,
                token: Token
                );

            cache?.Set(result.Id, result);

            return(result);
        }
Ejemplo n.º 2
0
        public Network ToRepositoryType(IRepositoryModelCache cache, IComputerRepository computerRepository, IUserRepository userRepository)
        {
            var result = new Network(
                address: Address,
                attatchedComputer: ComputerModel.ToRepositoryType(cache, AttatchedComputer_Id, computerRepository),
                devices: null,
                id: Id,
                lastPing: LastPing,
                name: Name,
                owner: UserModel.ToRepositoryType(cache, Owner_Id, userRepository)
                );

            cache?.Set(result.Id, result);

            return(result);
        }
Ejemplo n.º 3
0
        public static NetworkModel FromRepositoryType(Network repositoryModel)
        {
            if (repositoryModel == null)
            {
                return(null);
            }

            var attachedComputerRepositoryModel = ComputerModel.FromRepositoryType(repositoryModel.AttatchedComputer);
            var ownerRepositoryModel            = UserModel.FromRepositoryType(repositoryModel.Owner);

            var result = new NetworkModel
            {
                Address = repositoryModel.Address,
                AttatchedComputer_Id = attachedComputerRepositoryModel?.Id,
                Id       = repositoryModel.Id,
                LastPing = repositoryModel.LastPing,
                Name     = repositoryModel.Name,
                Owner_Id = ownerRepositoryModel?.Id,
            };

            return(result);
        }
Ejemplo n.º 4
0
        public Task ToRepositoryType(IRepositoryModelCache cache, IComputerRepository computerRepository, IScriptRepository scriptRepository, IUserRepository userRepository)
        {
            var cachedValue = cache?.Get <Task>(Id);

            if (cachedValue != null)
            {
                return(cachedValue);
            }

            var result = new Task(
                expiration: Expiration,
                id: Id,
                origin: Origin,
                owner: UserModel.ToRepositoryType(cache, Owner_Id, userRepository),
                receivedTimestamp: ReceivedTimestamp,
                script: ScriptModel.ToRepositoryType(cache, Script_Id, scriptRepository),
                target: ComputerModel.ToRepositoryType(cache, Target_Id, computerRepository)
                );

            cache?.Set(result.Id, result);

            return(result);
        }
Ejemplo n.º 5
0
        public static ComputerModel FromRepositoryType(Computer repositoryModel)
        {
            if (repositoryModel == null)
            {
                return(null);
            }

            var lastScriptRepositoryModel = ScriptModel.FromRepositoryType(repositoryModel.LastScript);
            var ownerRepositoryModel      = UserModel.FromRepositoryType(repositoryModel.Owner);

            var result = new ComputerModel
            {
                AccessKey     = repositoryModel.AccessKey,
                Address       = repositoryModel.Address,
                EncryptionKey = repositoryModel.EncryptionKey,
                Id            = repositoryModel.Id,
                LastPing      = repositoryModel.LastPing,
                LastScript_Id = lastScriptRepositoryModel?.Id,
                Name          = repositoryModel.Name,
                Owner_Id      = ownerRepositoryModel?.Id
            };

            return(result);
        }
Ejemplo n.º 6
0
        public static TaskModel FromRepositoryType(Task repositoryModel)
        {
            if (repositoryModel == null)
            {
                return(null);
            }

            var ownerRepositoryModel  = UserModel.FromRepositoryType(repositoryModel.Owner);
            var scriptRepositoryModel = ScriptModel.FromRepositoryType(repositoryModel.Script);
            var targetRepositoryModel = ComputerModel.FromRepositoryType(repositoryModel.Target);

            var result = new TaskModel
            {
                Expiration        = repositoryModel.Expiration,
                Id                = repositoryModel.Id,
                Origin            = repositoryModel.Origin,
                Owner_Id          = ownerRepositoryModel?.Id,
                ReceivedTimestamp = repositoryModel.ReceivedTimestamp,
                Script_Id         = scriptRepositoryModel?.Id,
                Target_Id         = targetRepositoryModel?.Id,
            };

            return(result);
        }