protected override void Add() { _ui.PrintLn("Authors:"); foreach (var a in _authorDao.GetAll()) { _ui.PrintLn(a); } int authorId = _ui.ReadInt("Author ID", 0); Author author = _authorDao.Get(authorId); if (author == null) { _ui.PrintLn("Author was not found!"); return; } string title = _ui.ReadString("Title", "Z"); _bookDao.Add(new Book(author, title)); }
protected override void Edit() { int id = _ui.ReadInt("Author ID", 0); Author author = _authorDao.Get(id); if (author == null) { _ui.PrintLn("Author not found"); return; } _ui.PrintLn(author); string firstName = _ui.ReadString("First name", author.FirstName); string lastName = _ui.ReadString("Last name", author.LastName); DateTime birthDate = _ui.ReadDate("Birth date", author.BirthDate); author.FirstName = firstName; author.LastName = lastName; author.BirthDate = birthDate; _authorDao.Update(author); }
public Author Get(int id) { return(_authorDao.Get(id)); }