示例#1
0
        public static async Task <WSClientNAV.Update_Result> UpdateAsync(ClientDetailsViewModel client, NAVWSConfigurations WSConfigurations)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }

            WSClientNAV.Update navUpdate = new WSClientNAV.Update()
            {
                teste = new WSClientNAV.teste
                {
                    //No = client.No,
                    Name                = client.Name,
                    Address             = client.Address,
                    Address_2           = client.Address_2,
                    Post_Code           = client.Post_Code,
                    City                = client.City,
                    Phone_No            = client.Phone_No,
                    E_Mail              = client.E_Mail,
                    Fax_No              = client.Fax_No,
                    Home_Page           = client.Home_Page,
                    County              = client.County,
                    VAT_Registration_No = client.VAT_Registration_No,
                    //Cliente_Associado = client.Cliente_Associado,
                    Associado_A_N = client.Associado_A_N,
                    //Tipo_Cliente = client.Tipo_Cliente,
                    //Natureza_Cliente = client.Natureza_Cliente
                }
            };

            //Configure NAV Client
            EndpointAddress ws_URL = new EndpointAddress(WSConfigurations.WS_Client_URL.Replace("Company", WSConfigurations.WS_User_Company));

            WSClientNAV.teste_PortClient ws_Client = new WSClientNAV.teste_PortClient(navWSBinding, ws_URL);
            ws_Client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Delegation;
            ws_Client.ClientCredentials.Windows.ClientCredential          = new NetworkCredential(WSConfigurations.WS_User_Login, WSConfigurations.WS_User_Password, WSConfigurations.WS_User_Domain);

            WSClientNAV.Read_Result resultRead = await ws_Client.ReadAsync(navUpdate.teste.No);

            navUpdate.teste.Key = resultRead.teste.Key;

            try
            {
                WSClientNAV.Update_Result result = await ws_Client.UpdateAsync(navUpdate);

                return(result);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
示例#2
0
        public static async Task <WSClientNAV.Update_Result> UpdateVATNumber(ClientDetailsViewModel client, NAVWSConfigurations WSConfigurations)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }

            WSClientNAV.Update navUpdate = new WSClientNAV.Update()
            {
                teste = new WSClientNAV.teste
                {
                    VAT_Registration_No = client.VAT_Registration_No,
                }
            };

            //Configure NAV Client
            EndpointAddress ws_URL = new EndpointAddress(WSConfigurations.WS_Client_URL.Replace("Company", WSConfigurations.WS_User_Company));

            WSClientNAV.teste_PortClient ws_Client = new WSClientNAV.teste_PortClient(navWSBinding, ws_URL);
            ws_Client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Delegation;
            ws_Client.ClientCredentials.Windows.ClientCredential          = new NetworkCredential(WSConfigurations.WS_User_Login, WSConfigurations.WS_User_Password, WSConfigurations.WS_User_Domain);

            WSClientNAV.Read_Result resultRead = await ws_Client.ReadAsync(navUpdate.teste.No);

            navUpdate.teste.Key = resultRead.teste.Key;

            try
            {
                WSClientNAV.Update_Result result = await ws_Client.UpdateAsync(navUpdate);

                return(result);
            }
            catch (Exception ex)
            {
                throw;
            }
        }