public async Task<IHttpActionResult> AddClient(ClientModel clientModel)
        {
            if (!this.ModelState.IsValid)
            {
                return this.BadRequest(this.ModelState);
            }

            var result = await this.repository.AddClient(clientModel);

            //IHttpActionResult errorResult = this.GetErrorResult(result);

            if (!result)
            {
                return this.BadRequest("Did not work to save client");
            }

            return this.Ok();
        }
Exemplo n.º 2
0
        public async Task<bool> AddClient(ClientModel clientModel)
        {
            Client client = new Client()
                                {
                                    Id = clientModel.Id,
                                    Secret = Helper.GetHash(clientModel.Secret),
                                    Name = clientModel.Name,
                                    ApplicationType = clientModel.ApplicationType,
                                    Active = clientModel.Active,
                                    RefreshTokenLifeTime = clientModel.RefreshTokenLifeTime,
                                    AllowedOrigin = clientModel.AllowedOrigin
                                };

            this.databaseContext.Clients.Add(client);

            return await this.databaseContext.SaveChangesAsync() > 0;
        }