Exemple #1
0
        public HttpServer(IHttpRequestHandler requestHandler,
                          IClientFactory clientFactory,
                          IClientContainer clientContainer,
                          IFirewall firewall) : this(requestHandler, clientFactory, clientContainer, firewall, null)
        {
            string serialized = System.IO.File.ReadAllText("rimserver.json");

            Options = JsonConvert.DeserializeObject <ServerOptions>(serialized);
        }
        private async Task <Client> Get(IClientContainer client)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            if (client.ClientId.HasValue)
            {
                return(await this.Context.Clients.AsNoTracking().FirstOrDefaultAsync(x => x.Id == client.ClientId));
            }
            return(null);
        }
Exemple #3
0
        public async Task ValidateAsync(IClientContainer clientContainer)
        {
            if (clientContainer == null)
            {
                throw new ArgumentNullException(nameof(clientContainer));
            }

            var client = await this.GetBy(clientContainer);

            if (clientContainer.ClientId.HasValue && client == null)
            {
                throw new InvalidOperationException($"Client not found by id {clientContainer.ClientId}");
            }
        }
Exemple #4
0
        public HttpServer(IHttpRequestHandler requestHandler,
                          IClientFactory clientFactory,
                          IClientContainer clientContainer,
                          IFirewall firewall,
                          ServerOptions options)
        {
            RequestHandler = requestHandler;
            ClientFactory  = clientFactory;
            Container      = Container;

            if (firewall != null)
            {
                Firewall = firewall;
            }

            if (options != null)
            {
                Options = options;
            }

            Logger = new ErrorLogger(this);
        }
 public async Task DeleteAsync(IClientContainer model)
 {
     Context.Clients.Remove(Mapper.Map <Client>(model));
     await Context.SaveChangesAsync();
 }
        public async Task <Domain.Client> GetByAsync(IClientContainer model)
        {
            var res = await Get(model);

            return(Mapper.Map <Domain.Client>(res));
        }
Exemple #7
0
 public async Task <Client> GetByAsync(IClientContainer client)
 {
     return(client.ClientId.HasValue
         ? this.Mapper.Map <Client>(await this.Context.Client.FirstOrDefaultAsync(x => x.Id == client.ClientId))
         : null);
 }
Exemple #8
0
 private Task <Client> GetBy(IClientContainer clientContainer)
 {
     return(this.ClientDataAccess.GetByAsync(clientContainer));
 }