Esempio n. 1
0
        public WorkerEditor CreateOrModify(
            string name,
            EndpointResource endpoint,
            WorkerPoolResource[] pools)
        {
            var existing = repository.FindByName(name);

            if (existing == null)
            {
                Instance = repository.Create(new WorkerResource
                {
                    Name          = name,
                    Endpoint      = endpoint,
                    WorkerPoolIds = new ReferenceCollection(pools.Select(e => e.Id))
                });
            }
            else
            {
                existing.Name     = name;
                existing.Endpoint = endpoint;
                existing.WorkerPoolIds.ReplaceAll(pools.Select(e => e.Id));

                Instance = repository.Modify(existing);
            }

            return(this);
        }
Esempio n. 2
0
        public async Task <WorkerEditor> CreateOrModify(
            string name,
            EndpointResource endpoint,
            WorkerPoolResource[] workerpools)
        {
            var existing = await repository.FindByName(name).ConfigureAwait(false);

            if (existing == null)
            {
                Instance = await repository.Create(new WorkerResource
                {
                    Name          = name,
                    Endpoint      = endpoint,
                    WorkerPoolIds = new ReferenceCollection(workerpools.Select(e => e.Id))
                }).ConfigureAwait(false);
            }
            else
            {
                existing.Name     = name;
                existing.Endpoint = endpoint;
                existing.WorkerPoolIds.ReplaceAll(workerpools.Select(e => e.Id));

                Instance = await repository.Modify(existing).ConfigureAwait(false);
            }

            return(this);
        }