private static bool ValidateRequest(Model.Request.BookRequest request)
 {
     Model.Response.CodeResponse codeResponse = new Model.Response.CodeResponse();
     if (request.idBook < 0)
     {
         codeResponse.code    = 101;
         codeResponse.message = "ID Number invalid";
         return(false);
     }
     return(true);
 }
예제 #2
0
 public static Model.Response.BookResponse GetBookById(Model.Request.BookRequest request)
 {
     Model.Response.BookResponse response = new Model.Response.BookResponse();
     try
     {
         var dataservice = new Connection.DbContext();
         List <Model.Entities.BookEntity> listBooks = dataservice.GetListByParameter <Model.Entities.BookEntity, object>("getBooksById_SelectCommand", request);
         response.bookEntity = listBooks;
     }
     catch (Exception ex)
     {
         response.code    = 500;
         response.message = ex.Message;
     }
     return(response);
 }
 public static Model.Response.BookResponse GetBookById(Model.Request.BookRequest request)
 {
     Model.Response.BookResponse response = new Model.Response.BookResponse();
     try
     {
         if (ValidateRequest(request))
         {
             response = Data.BookData.GetBookById(request);
             if (ValidateResponse(response))
             {
                 response.code    = 100;
                 response.message = "Success";
             }
         }
     }
     catch (Exception ex)
     {
         response.code    = 500;
         response.message = ex.Message;
     }
     return(response);
 }
 public ActionResult <Model.Response.BookResponse> GetBookById(Model.Request.BookRequest request)
 {
     Model.Response.BookResponse response = Business.BookBusiness.GetBookById(request);
     return(response);
 }