Пример #1
0
 public OperationResultSet <Book> GetAllBooksByGenre(string genre, string userName, string guid)
 {
     if (!CheckAuthenticated(userName, guid))
     {
         return(new OperationResultSet <Book>(Library.Models.OperationResult.ErrorEnum.NotAuthenticated,
                                              "Please authenticate first!"));
     }
     if (String.IsNullOrEmpty(genre))
     {
         return(new OperationResultSet <Book>(Library.Models.OperationResult.ErrorEnum.InvalidInputData, "Invalid or missing book genre"));
     }
     using (BookData dataProvider = new BookData())
     {
         try
         {
             Book[] result = dataProvider.GetAllBooksByGenre(genre);
             if (result == null)
             {
                 return(new OperationResultSet <Book>(new List <Book>()));
             }
             return(new OperationResultSet <Book>(new List <Book>(result)));
         }
         catch (Exception ex)
         {
             System.Diagnostics.Debug.WriteLine("BookManagement : GetAllBooksByGenre : " + ex.StackTrace);
             return(new OperationResultSet <Book>(Library.Models.OperationResult.ErrorEnum.InternalProblem, "Some internal problem has occured"));
         }
     }
 }