public static async Task <WSCustomerNAV.Delete_Result> DeleteAsync(string CustomerNo, NAVWSConfigurations WSConfigurations) { if (CustomerNo == null) { throw new ArgumentNullException("CustomerNo"); } //Configure NAV Client EndpointAddress ws_URL = new EndpointAddress(WSConfigurations.WS_Customer_URL.Replace("Company", WSConfigurations.WS_User_Company)); WSCustomerNAV.WSCustomer_PortClient ws_Client = new WSCustomerNAV.WSCustomer_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); try { WSCustomerNAV.Read_Result resultRead = await ws_Client.ReadAsync(CustomerNo); WSCustomerNAV.Delete_Result result = await ws_Client.DeleteAsync(resultRead.WSCustomer.Key); return(result); } catch (Exception ex) { throw; } }
public static async Task <ClientDetailsViewModel> GetByNoAsync(string CustomerNo, NAVWSConfigurations WSConfigurations) { if (CustomerNo == null) { throw new ArgumentNullException("CustomerNo"); } //Configure NAV Client EndpointAddress WS_URL = new EndpointAddress(WSConfigurations.WS_Customer_URL.Replace("Company", WSConfigurations.WS_User_Company)); WSCustomerNAV.WSCustomer_PortClient WS_Client = new WSCustomerNAV.WSCustomer_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); try { WSCustomerNAV.Read_Result result = await WS_Client.ReadAsync(CustomerNo); var WSCustomer = result.WSCustomer; var client = MapCustomerNAVToCustomerModel(WSCustomer); return(client); } catch (Exception ex) { throw; } }
public static async Task <WSCustomerNAV.Update_Result> UpdateAsync(ClientDetailsViewModel client, NAVWSConfigurations WSConfigurations) { if (client == null) { throw new ArgumentNullException("client"); } client.Cliente_Interno = false; WSCustomerNAV.Update navUpdate = new WSCustomerNAV.Update() { WSCustomer = MapCustomerModelToCustomerNAV(client) }; //Configure NAV Client EndpointAddress ws_URL = new EndpointAddress(WSConfigurations.WS_Customer_URL.Replace("Company", WSConfigurations.WS_User_Company)); WSCustomerNAV.WSCustomer_PortClient ws_Client = new WSCustomerNAV.WSCustomer_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); WSCustomerNAV.Read_Result resultRead = await ws_Client.ReadAsync(navUpdate.WSCustomer.No); navUpdate.WSCustomer.Key = resultRead.WSCustomer.Key; try { navUpdate.WSCustomer.Utilizador_Alteracao_eSUCH = client.Utilizador_Alteracao_eSUCH; navUpdate.WSCustomer.Abrigo_Lei_CompromissoSpecified = true; navUpdate.WSCustomer.BlockedSpecified = true; navUpdate.WSCustomer.Cliente_AssociadoSpecified = true; navUpdate.WSCustomer.Cliente_InternoSpecified = true; navUpdate.WSCustomer.Cliente_NacionalSpecified = true; navUpdate.WSCustomer.Data_Cliente_PaiSpecified = true; navUpdate.WSCustomer.Natureza_ClienteSpecified = true; navUpdate.WSCustomer.Regiao_ClienteSpecified = true; navUpdate.WSCustomer.Taxa_AprovisionamentoSpecified = true; navUpdate.WSCustomer.Tipo_ClienteSpecified = true; WSCustomerNAV.Update_Result result = await ws_Client.UpdateAsync(navUpdate); return(result); } catch (Exception ex) { throw; } }