public static BookActiveRecord Find(int _id) { BookActiveRecord book = new BookActiveRecord(); var bookGateWay = new BookTDG(); DataTable dt = bookGateWay.GetBookByID(_id); book = MapResultsetToObject(dt.Rows[0]); return(book); }
public static BookInRentalActiveRecord MapResultsetToObject(DataRow dr) { BookInRentalActiveRecord NewBook = new BookInRentalActiveRecord(); var bookTemp = new BookTDG(); var rentalTemp = new RentalTDG(); NewBook.ID = Convert.ToInt32(dr.ItemArray[0].ToString()); NewBook.Book = BookActiveRecord.MapResultsetToObject(bookTemp.GetBookByID(Convert.ToInt32(dr.ItemArray[1].ToString())).Rows[0]); NewBook.Rental = RentalActiveRecord.MapResultsetToObject(rentalTemp.GetRentalByID(Convert.ToInt32(dr.ItemArray[2].ToString())).Rows[0]); return(NewBook); }
public void Save() { var bookGateWay = new BookTDG(); if (ID != null) { bookGateWay.Update((int)this.ID, (int)this.Author.ID, this.Title, this.Genre, (int)this.Available); } else { int tmpId = bookGateWay.Insert((int)this.Author.ID, this.Title, this.Genre, (int)this.Available); ID = tmpId; } }
public static List <BookActiveRecord> Find() { List <BookActiveRecord> booksList = new List <BookActiveRecord>(); var bookGateWay = new BookTDG(); DataTable dt = bookGateWay.Find(); foreach (DataRow dr in dt.Rows) { booksList.Add(MapResultsetToObject(dr)); } return(booksList); }