Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public static Network ToRepositoryType(IRepositoryModelCache cache, int?id, INetworkRepository networkRepository)
        {
            if (id == null)
            {
                return(null);
            }

            var cachedValue = cache?.Get <Network>(id);

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

            if (networkRepository == null)
            {
                new NetworkModel
                {
                    Id = id.Value
                }.ToRepositoryType(cache, (IComputerRepository)null, (IUserRepository)null);
            }

            return(networkRepository.Get(id.Value, cache));
        }
Exemplo n.º 3
0
        public static User ToRepositoryType(IRepositoryModelCache cache, int?id, IUserRepository userRepository)
        {
            if (id == null)
            {
                return(null);
            }

            var cachedValue = cache?.Get <User>(id);

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

            if (userRepository == null)
            {
                return(new UserModel
                {
                    Id = id.Value
                }.ToRepositoryType((IRepositoryModelCache)null));
            }

            return(userRepository.Get(id.Value, cache));
        }
Exemplo n.º 4
0
        public static Computer ToRepositoryType(IRepositoryModelCache cache, int?id, IComputerRepository computerRepository)
        {
            if (id == null)
            {
                return(null);
            }

            var cachedValue = cache?.Get <Computer>(id);

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

            if (computerRepository == null)
            {
                return(new ComputerModel
                {
                    Id = id.Value
                }.ToRepositoryType(cache, (IScriptRepository)null, (IUserRepository)null));
            }

            return(computerRepository.Get(id.Value, cache));
        }
Exemplo n.º 5
0
        public static Script ToRepositoryType(IRepositoryModelCache cache, int?id, IScriptRepository scriptRepository)
        {
            if (id == null)
            {
                return(null);
            }

            var cachedValue = cache?.Get <Script>(id);

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

            if (scriptRepository == null)
            {
                return(new ScriptModel
                {
                    Id = id.Value
                }.ToRepositoryType((IRepositoryModelCache)null));
            }

            return(scriptRepository.Get(id.Value, cache));
        }