diff --git a/src/team4.cs b/src/team4.cs index 8f36e2f..2d86756 100644 --- a/src/team4.cs +++ b/src/team4.cs @@ -213,6 +213,41 @@ public class Team4 } } + public static AuthorDto GetAuthorById(SqliteConnection conn, int authorID) + { + try + { + using (var command = conn.CreateCommand()) + { + command.CommandText = @" + SELECT author.ID + FROM Authors author + WHERE author.ID = @aid;"; + command.Parameters.AddWithValue("@aid", authorID); + + using (var reader = command.ExecuteReader()) + { + while (reader.Read()) + { + return new AuthorDto + { + Id = reader.GetInt32(0), + Name = reader.GetString(1), + Surname = reader.GetString(2), + DateOfBirth = reader.GetDateTime(3) + }; + } + } + return null; + } + } + catch (Exception ex) + { + Console.WriteLine($"Error in GetAuthorById: {ex.Message}"); + throw; + } + } + public static void GetBooksBy(SqliteConnection conn) { throw new NotImplementedException();