Exemplo n.º 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(); }); }
 }
Exemplo n.º 2
0
 public override object ReadObject(XmlReader reader)
 {
     GiveBackBook GiveBackBookField = null;
     if (IsParentStartElement(reader, false, true))
     {
         GiveBackBookField = new GiveBackBook();
         reader.Read();
         if (IsChildStartElement(reader, "userID", false, false))
         {
             reader.Read();
             GiveBackBookField.userID = XmlConvert.ToInt32(reader.ReadString());
             reader.ReadEndElement();
         }
         if (IsChildStartElement(reader, "bookID", false, false))
         {
             reader.Read();
             GiveBackBookField.bookID = XmlConvert.ToInt32(reader.ReadString());
             reader.ReadEndElement();
         }
         reader.ReadEndElement();
     }
     return GiveBackBookField;
 }
Exemplo n.º 3
0
        public virtual GiveBackBookResponse GiveBackBook(GiveBackBook req)
        {
            // Create request header
            String action;
            action = "http://tempuri.org/IService/GiveBackBook";
            WsWsaHeader header;
            header = new WsWsaHeader(action, null, EndpointAddress, m_version.AnonymousUri, null, null);
            WsMessage request = new WsMessage(header, req, WsPrefix.None);

            // Create request serializer
            GiveBackBookDataContractSerializer reqDcs;
            reqDcs = new GiveBackBookDataContractSerializer("GiveBackBook", "http://tempuri.org/");
            request.Serializer = reqDcs;
            request.Method = "GiveBackBook";

            // Send service request
            m_requestChannel.Open();
            WsMessage response = m_requestChannel.Request(request);
            m_requestChannel.Close();

            // Process response
            GiveBackBookResponseDataContractSerializer respDcs;
            respDcs = new GiveBackBookResponseDataContractSerializer("GiveBackBookResponse", "http://tempuri.org/");
            GiveBackBookResponse resp;
            resp = ((GiveBackBookResponse)(respDcs.ReadObject(response.Reader)));
            response.Reader.Dispose();
            response.Reader = null;
            return resp;
        }