コード例 #1
0
 public void ReturnBook()
 {
     try
     {//show a loading message
         View.ShowLoading();
         using (IServiceClientProxy proxy = new IServiceClientProxy(binding, new ProtocolVersion11()))
         {
             //execute the return request
             int bookId = LibraryModelSingleton.Instance.Book.ID;
             int userId = LibraryModelSingleton.Instance.User.ID;
             GiveBackBook returnRequest = new GiveBackBook() { bookID = bookId, userID = userId };
             var response = proxy.GiveBackBook(returnRequest);
             //show positive a message if the result is valid otherwise a negative message
             //and return in the welcome page
             state = InnerState.WELCOME;
             string msg = (response.GiveBackBookResult) ? OPERATION_COMPLETED_MSG : OPERATION_FAILED_MSG;
             View.ShowMessageWithButton(msg, () => { View.ShowWelcomePage(); });
         }
     }
     //show a message and then returns in the login page
     catch (Exception) { View.ShowMessageWithButton(ERROR_MSG, () => { this.Logout(); }); }
 }