Exemplo n.º 1
0
 private IDataResult <List <BookDetailDto> > CheckParametres(int writerId, int publisherId, int categoryId)
 {
     if (writerId > 0 && publisherId > 0 && categoryId > 0)
     {
         return(new SuccessDataResult <List <BookDetailDto> >(_bookDal.GetBooksByFilter(b => b.WriterId == writerId && b.PublisherId == publisherId && b.CategoryId == categoryId)));
     }
     else if (writerId > 0 && publisherId > 0)
     {
         return(new SuccessDataResult <List <BookDetailDto> >(_bookDal.GetBooksByFilter(b => b.WriterId == writerId && b.PublisherId == publisherId)));
     }
     else if (categoryId > 0 && publisherId > 0)
     {
         return(new SuccessDataResult <List <BookDetailDto> >(_bookDal.GetBooksByFilter(b => b.CategoryId == categoryId && b.PublisherId == publisherId)));
     }
     else if (categoryId > 0 && writerId > 0)
     {
         return(new SuccessDataResult <List <BookDetailDto> >(_bookDal.GetBooksByFilter(b => b.CategoryId == categoryId && b.WriterId == writerId)));
     }
     else if (publisherId > 0)
     {
         return(new SuccessDataResult <List <BookDetailDto> >(_bookDal.GetBooksByFilter(b => b.PublisherId == publisherId)));
     }
     else if (categoryId > 0)
     {
         return(new SuccessDataResult <List <BookDetailDto> >(_bookDal.GetBooksByFilter(b => b.CategoryId == categoryId)));
     }
     else if (writerId > 0)
     {
         return(new SuccessDataResult <List <BookDetailDto> >(_bookDal.GetBooksByFilter(b => b.WriterId == writerId)));
     }
     else if (writerId == 0 && categoryId == 0 && publisherId == 0)
     {
         return(new SuccessDataResult <List <BookDetailDto> >(_bookDal.GetBookDetailsDto()));
     }
     return(new ErrorDataResult <List <BookDetailDto> >(Messages.ParametersNotFound));
 }