// GET: api/categories public IEnumerable<Categorie> Getcategories() { var queryResult = db.categories.ToList(); List<Categorie> listCategorie = new List<Categorie>(); foreach (var c in queryResult) { Categorie categorie = new Categorie(); categorie.CodeCategorie = c.CodeCategorie; categorie.LibelleCategorie = c.LibelleCategorie; listCategorie.Add(categorie); } return listCategorie; }
// GET: api/authors public IEnumerable<Author> Getauthors() { var queryResult = db.authors.ToList(); List<Author> listAuthor = new List<Author>(); foreach (var a in queryResult) { Author author = new Author(); author.NameAuthor = a.NameAuthor; author.NumAuthor = a.NumAuthor; List<Book> listBook = new List<Book>(); foreach (var b in a.books) { Book book = new Book(); book.NumBook = b.NumBook; book.Title = b.Title; book.Editor = b.Editor; book.YearPublication = b.YearPublication; book.DateEntry = b.DateEntry; book.Rangement = b.Rangement; book.Statut = b.Statut; var queryResultCategorie = (from c in db.categories where c.CodeCategorie == b.CodeCategorie select c).First(); Categorie categorie = new Categorie(); categorie.CodeCategorie = queryResultCategorie.CodeCategorie; categorie.LibelleCategorie = queryResultCategorie.LibelleCategorie; book.Categorie = categorie; book.NumberReservation = b.reservations.Count(); listBook.Add(book); } author.Book = listBook; listAuthor.Add(author); } return listAuthor; }
private void fillBook(Book book, book b) { book.NumBook = b.NumBook; book.Title = b.Title; book.Editor = b.Editor; book.YearPublication = b.YearPublication; book.DateEntry = b.DateEntry; book.Rangement = b.Rangement; book.Statut = b.Statut; var queryResultCategorie = (from c in db.categories where c.CodeCategorie == b.CodeCategorie select c).First(); Categorie categorie = new Categorie(); categorie.CodeCategorie = queryResultCategorie.CodeCategorie; categorie.LibelleCategorie = queryResultCategorie.LibelleCategorie; book.Categorie = categorie; List<Author> listAuthor = new List<Author>(); foreach (var a in b.authors) { Author author = new Author(); author.NumAuthor = a.NumAuthor; author.NameAuthor = a.NameAuthor; listAuthor.Add(author); } book.Author = listAuthor; book.NumberReservation = b.reservations.Count(); }
public Book() { categorie = new Categorie(); author = new List<Author>(); }