예제 #1
0
 public OperationResultSet <Book> GetAllBooksByType(string type, string userName, string guid)
 {
     if (!CheckAuthenticated(userName, guid))
     {
         return(new OperationResultSet <Book>(Library.Models.OperationResult.ErrorEnum.NotAuthenticated,
                                              "Please authenticate first!"));
     }
     if (String.IsNullOrEmpty(type))
     {
         return(new OperationResultSet <Book>(Library.Models.OperationResult.ErrorEnum.InvalidInputData, "Invalid or missing book type"));
     }
     using (BookData dataProvider = new BookData())
     {
         try
         {
             Book[] result = dataProvider.GetAllBooksByType(type);
             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 : GetAllBooksByType : " + ex.StackTrace);
             return(new OperationResultSet <Book>(Library.Models.OperationResult.ErrorEnum.InternalProblem, "Some internal problem has occured"));
         }
     }
 }