Esempio n. 1
0
 // GET: Book
 public ActionResult GetBooks(BookFilter filter)
 {
     var data = _bookService.GetByFilter(1, filter);
     return new JsonResult
     {
         Data = data,
         JsonRequestBehavior = JsonRequestBehavior.AllowGet
     };
 }
Esempio n. 2
0
 public List<BookModel> GetByFilter(int userId, BookFilter filter)
 {
     if(filter.AuthorId == 0 && filter.CategoryId == 0)
         multiResult = _rep.GetAll<BookModel, Book.Data.Book>();
     else if(filter.AuthorId == 0)
         multiResult = _rep.GetAll<BookModel, Book.Data.Book>(x => x.CategoryId == filter.CategoryId);
     else if(filter.CategoryId == 0)
         multiResult = _rep.GetAll<BookModel, Book.Data.Book>(x => x.AuthorId == filter.AuthorId);
     else
         multiResult = _rep.GetAll<BookModel, Book.Data.Book>(x => x.AuthorId == filter.AuthorId && x.CategoryId == filter.CategoryId);
     return multiResult;
 }