public async Task <IEnumerable <T> > GetSortedRecordsAsync <T>(string tableName, string orderBy, string criterium) { List <ISqlTableModel> modelsList = new List <ISqlTableModel>(); using (var message = new HttpRequestMessage(HttpMethod.Get, ApiCommandProvider.SortedRecordsHttpRequest(tableName, orderBy, criterium))) using (var response = await httpClient.SendAsync(message)) { response.EnsureSuccessStatusCode(); var stream = await response.Content.ReadAsStreamAsync(); return(DeserializeJsonFromStream <IEnumerable <T> >(stream)); } }
public async Task <IEnumerable <T> > GetRecordAsync <T>(string tableName) { // TODO: SPRAWDZIC CZY IMPLEMENTUJE INTERFACE!! List <ISqlTableModel> modelsList = new List <ISqlTableModel>(); using (var message = new HttpRequestMessage(HttpMethod.Get, ApiCommandProvider.GetRecordHttpRequest(tableName))) using (var response = await httpClient.SendAsync(message)) { response.EnsureSuccessStatusCode(); var stream = await response.Content.ReadAsStreamAsync(); return(DeserializeJsonFromStream <IEnumerable <T> >(stream)); } }
public async Task <IEnumerable <string> > GetColumnNamesAsync(string tableName) { using (var message = new HttpRequestMessage(HttpMethod.Get, ApiCommandProvider.GetColumnNamesHttpRequest(tableName))) using (var response = await httpClient.SendAsync(message)) { response.EnsureSuccessStatusCode(); var columns = await response.Content.ReadAsStringAsync(); columns = columns.Remove(0, 1); var columnNames = columns.Split("."); var x = columnNames.ToList(); x.RemoveAt(x.Count - 1); return(x); } }
public async Task <bool> CreateNewRecordAsync(string tableName, IEnumerable <string> valuesList) { using (var message = new HttpRequestMessage(HttpMethod.Get, ApiCommandProvider.CreateNewRecord(tableName, valuesList.ToList()))) using (var response = await httpClient.SendAsync(message)) { response.EnsureSuccessStatusCode(); var str = await response.Content.ReadAsStringAsync(); if (str == "ERROR") { return(false); } return(true); } }
public async Task <bool> DeleteRecordAsync(string tableName, string primaryKey, string primaryKeyName) { using (var message = new HttpRequestMessage(HttpMethod.Get, ApiCommandProvider.DeleteRecordHttpRequest(tableName, primaryKey, primaryKeyName))) using (var response = await httpClient.SendAsync(message)) { response.EnsureSuccessStatusCode(); var str = await response.Content.ReadAsStringAsync(); if (str == "ERROR") { return(false); } return(true); } }
public async Task <IDictionary <int, string> > GetColumnTypesAsync(string tableName) { using (var message = new HttpRequestMessage(HttpMethod.Get, ApiCommandProvider.GetColumnTypesHttpRequest(tableName))) using (var response = await httpClient.SendAsync(message)) { response.EnsureSuccessStatusCode(); var columns = await response.Content.ReadAsStringAsync(); var columnTypes = columns.Split("."); var x = columnTypes.ToList(); x.RemoveAt(x.Count - 1); var dictionary = new Dictionary <int, string>(); for (int i = 0; i < x.Count; i++) { dictionary.Add(i, x[i]); } return(dictionary); } }