public void BorrowBook() { try { //show a loading message View.ShowLoading(); using (IServiceClientProxy proxy = new IServiceClientProxy(binding, new ProtocolVersion11())) { //execute the borrow request int bookId = LibraryModelSingleton.Instance.Book.ID; int userId = LibraryModelSingleton.Instance.User.ID; Borrow borrowRequest = new Borrow() { bookID = bookId, userID = userId }; BorrowResponse response = proxy.Borrow(borrowRequest); //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.BorrowResult.StartDate.Equals(DateTime.MinValue)) ? BORROW_FAILED_MSG : OPERATION_COMPLETED_MSG; View.ShowMessageWithButton(msg, () => { View.ShowWelcomePage(); }); } } //show a message and then returns in the login page catch (Exception) { View.ShowMessageWithButton(ERROR_MSG, () => { this.Logout(); }); } }