public virtual ValidationResponse Validate(string networkID)
 {
     return(_next != null?_next.Validate(networkID) : new ValidationResponse
     {
         isValid = false, message = "Invalid Network Identifier"
     });
 }
Beispiel #2
0
        public async Task <NetworkEndpoint> CreateAsync(NetworkEndpoint item)
        {
            validator.Validate(item);

            using (var cn = new SqlConnection(opts.ConnectionString))
            {
                await cn.OpenAsync();

                var id = cn.ExecuteScalar <int>(
                    queryCreate,
                    new
                {
                    name        = item.Name,
                    address     = item.Address.AbsoluteUri,
                    issuer      = item.Issuer,
                    keyid       = item.KeyId,
                    certificate = item.Certificate
                },
                    commandTimeout: opts.DefaultTimeout,
                    commandType: CommandType.StoredProcedure
                    );

                var created = new NetworkEndpoint
                {
                    Id          = id,
                    Name        = item.Name,
                    Address     = item.Address,
                    Issuer      = item.Issuer,
                    KeyId       = item.KeyId,
                    Certificate = item.Certificate
                };

                log.LogInformation("Created NetworkEndpoint. Endpoint:{@Endpoint}", created);

                return(created);
            }
        }
        public IEnumerable <IProgrammer> GetAll()
        {
            Network network;

            TryGetNetwork(out network);

            try
            {
                _networkValidator.Validate(network);
            }
            catch (ArgumentException e)
            {
                throw new ArgumentException($"File {_networkFilePath} is not a valid ProNet data file");
            }

            return(network.Programmer.Select(p => new Programmer(p.name, p.Recommendations, p.Skills)));
        }