public void Save() { var bookGateWay = new AuthorTDG(); int tmpId = bookGateWay.Insert(this.Name, this.Surname); ID = tmpId; }
public static BookActiveRecord MapResultsetToObject(DataRow dr) { BookActiveRecord NewBook = new BookActiveRecord(); var authorTemp = new AuthorTDG(); NewBook.ID = Convert.ToInt32(dr.ItemArray[0].ToString()); NewBook.Author = AuthorActiveRecord.MapResultsetToObject(authorTemp.GetAuthorByID(Convert.ToInt32(dr.ItemArray[1].ToString())).Rows[0]); NewBook.Title = dr.ItemArray[2].ToString(); NewBook.Genre = dr.ItemArray[3].ToString(); NewBook.Available = Convert.ToInt32(dr.ItemArray[4].ToString()); return(NewBook); }
public static List <AuthorActiveRecord> Find() { List <AuthorActiveRecord> authorsList = new List <AuthorActiveRecord>(); var authorGateWay = new AuthorTDG(); DataTable dt = authorGateWay.Find(); foreach (DataRow dr in dt.Rows) { authorsList.Add(MapResultsetToObject(dr)); } return(authorsList); }