public static Band GetBandAsync2(string selectedBand) { Band gevondenBand = new Band(); //ObservableCollection<Band> lst = await GetBandsAsync(); return gevondenBand; }
public static Band GetBandByID(int id) { Band gevondenBand = new Band(); string sql = "SELECT * FROM Bands WHERE ID=@id;"; DbParameter parID = Database.AddParameter("@id", id); DbDataReader reader = Database.GetData(sql, parID); while (reader.Read()) { gevondenBand = CreateBand(reader); } return gevondenBand; }
private static Band CreateBand(DbDataReader reader) { Band band = new Band(); band.ID = Convert.ToInt32(reader["ID"].ToString()); band.Name = Convert.ToString(reader["Name"]); band.Picture = (byte[])reader["Picture"]; band.Descr = Convert.ToString(reader["Description"]); band.Twitter = Convert.ToString(reader["Twitter"]); band.Facebook = Convert.ToString(reader["Facebook"]); band.Genres = GenreRepository.GetGenresByID (Convert.ToInt32(reader["ID"])); return band; }
public async void GetBandFromAPI(int id) { List<Band> Bands = new List<FestivalLibPortable.Band>(); HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml")); HttpResponseMessage response = await client.GetAsync("http://localhost:18358/api/band/" + id); if (response.IsSuccessStatusCode) { Stream stream = await response.Content.ReadAsStreamAsync(); DataContractSerializer dxml = new DataContractSerializer(typeof(FestivalLibPortable.Band)); Band = dxml.ReadObject(stream) as Band; stream.Dispose(); Bands.Add(Band); DeBand.ItemsSource = Bands; } }