public IActionResult List(int?authorID, int?borrowerID) { if (authorID == null && borrowerID == null) { // show all music var musics = _musicRepository.GetAllWithAuthor(); // check music // return CheckMusics(musics); if (musics.Count() == 0) { return(View("Empty")); } else { return(View(musics)); } } else if (authorID != null) { // filter by author id var author = _authorRepository.GetWithMusics((int)authorID); // check author musics if (author.Musics.Count() == 0) { return(View("AuthorEmpty", author)); } else { return(View(author.Musics)); } } else if (borrowerID != null) { // filter by borrower id var musics = _musicRepository.FindWithAuthorAndBorrower(music => music.BorrowerID == borrowerID); // check borrower musics // return CheckMusics(musics); if (musics.Count() == 0) { return(View("Empty")); } else { return(View(musics)); } } else { // throw exception throw new ArgumentException(); } }
public IActionResult List() { // load all borrowed musics var borrowedMusics = _musicRepository.FindWithAuthorAndBorrower(x => x.BorrowerID != 0); // check the musics collection if (borrowedMusics == null || borrowedMusics.ToList().Count() == 0) // borrowedMusics == null || { return(View("Empty")); } return(View(borrowedMusics)); }