Exemplo n.º 1
0
 public ActionResult DisplayPaginatedAlbums(int page = 1, int pageSize = 10)
 {
     if (page < 0)
     {
         throw new ArgumentException("page is less then 0", nameof(page));
     }
     try
     {
         var resultOfAlbumPagination = _musicStoreDisplayService.DisplayAlbumsWithPagination(page, pageSize);
         if (resultOfAlbumPagination == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, "Something wrong with pagination or albums in db"));
         }
         return(View(resultOfAlbumPagination));
     }
     catch (ArgumentException exception)
     {
         var innerExcept = exception.InnerException != null ? exception.InnerException.Message : " ";
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, $"{innerExcept} and {exception.Message}"));
     }
     catch (Exception exception)
     {
         var innerExcept = exception.InnerException != null ? exception.InnerException.Message : " ";
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, $"{innerExcept} and {exception.Message}"));
     }
 }