public Client GetOneClient(string clientId) { var client = (Client)null; List<Dictionary<string, string>> list = _database.Query("Select * from Clients where Id = @id", new Dictionary<string, object>() { { "@id", clientId } }); if (list != null && list.Count == 1) { Dictionary<string, string> dictionary = list[0]; client = new Client {Id = dictionary["Id"], Secret = dictionary["Secret"], Name = dictionary["Name"]}; if (int.Parse(dictionary["ApplicationType"]) == 1) client.ApplicationType = ApplicationTypes.NativeConfidential; else if (int.Parse(dictionary["ApplicationType"]) == 0) client.ApplicationType = ApplicationTypes.JavaScript; client.Active = int.Parse(dictionary["Active"]) == 1; client.RefreshTokenLifeTime = int.Parse(dictionary["RefreshTokenLifeTime"]); client.AllowedOrigin = dictionary["AllowedOrigin"]; } return client; }
public IEnumerable<Client> GetAllClients() { IList<Client> list1 = new List<Client>(); List<Dictionary<string, string>> list2 = _database.Query("Select * from Clients"); if (list2 != null) { foreach (var dictionary in list2) { var client = new Client { Id = dictionary["Id"], Secret = dictionary["Secret"], Name = dictionary["Name"] }; if (int.Parse(dictionary["ApplicationType"]) == 1) client.ApplicationType = ApplicationTypes.NativeConfidential; else if (int.Parse(dictionary["ApplicationType"]) == 0) client.ApplicationType = ApplicationTypes.JavaScript; client.Active = int.Parse(dictionary["Active"]) == 1; client.RefreshTokenLifeTime = int.Parse(dictionary["RefreshTokenLifeTime"]); client.AllowedOrigin = dictionary["AllowedOrigin"]; list1.Add(client); } } return list1; }