public async Task <ActionResult <List <FirmaDto> > > GetAll() { try { var firmas = (await _dapperFirmaService.QueryAsync("SELECT * FROM Firma")).ToList(); foreach (Firma firma in firmas) { var arabas = (await _dapperArabaService.QueryAsync($"SELECT * FROM Araba WHERE FirmaID = {firma.FirmaID}")).ToList(); firma.Arabas = arabas; } return(Ok(firmas)); } catch (Exception ex) { return(NotFound(ex.Message)); } }
public async Task <ActionResult <KiralamaDto> > GetAll() { try { var kiralamas = (await _dapperKiralamaService.QueryAsync("SELECT * FROM Kiralama")).ToList(); foreach (Kiralama kiralama in kiralamas) { var alicis = (await _dapperAliciService.QueryAsync($"SELECT * FROM Alici WHERE AliciID = {kiralama.AliciID}")).ToList(); kiralama.Alicis = alicis; var arabas = (await _dapperArabaService.QueryAsync($"SELECT * FROM Araba WHERE ArabaID = {kiralama.ArabaID}")).ToList(); kiralama.Arabas = arabas; } return(Ok(kiralamas)); } catch (Exception ex) { return(NotFound(ex.Message)); } }