public static async Task <WSVendorNAV.ReadMultiple_Result> GetAllAsync(int size, NAVWSConfigurations WSConfigurations)
        {
            //Configure NAV Vendor
            EndpointAddress WS_URL = new EndpointAddress(WSConfigurations.WS_Vendor_URL.Replace("Company", WSConfigurations.WS_User_Company));

            WSVendorNAV.WSVendor_PortClient WS_Vendor = new WSVendorNAV.WSVendor_PortClient(navWSBinding, WS_URL);
            WS_Vendor.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Delegation;
            WS_Vendor.ClientCredentials.Windows.ClientCredential          = new NetworkCredential(WSConfigurations.WS_User_Login, WSConfigurations.WS_User_Password, WSConfigurations.WS_User_Domain);

            var filter = new WSVendorNAV.WSVendor_Filter {
                Field = WSVendorNAV.WSVendor_Fields.No, Criteria = "200*"
            };
            var filterArray = new WSVendorNAV.WSVendor_Filter[] { filter };

            try
            {
                WSVendorNAV.ReadMultiple_Result result = await WS_Vendor.ReadMultipleAsync(filterArray, null, size);

                return(result);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public static async Task <WSVendorNAV.Delete_Result> DeleteAsync(string VendorNo, NAVWSConfigurations WSConfigurations)
        {
            if (VendorNo == null)
            {
                throw new ArgumentNullException("VendorNo");
            }

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

            WSVendorNAV.WSVendor_PortClient ws_Vendor = new WSVendorNAV.WSVendor_PortClient(navWSBinding, ws_URL);
            ws_Vendor.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Delegation;
            ws_Vendor.ClientCredentials.Windows.ClientCredential          = new NetworkCredential(WSConfigurations.WS_User_Login, WSConfigurations.WS_User_Password, WSConfigurations.WS_User_Domain);

            try
            {
                WSVendorNAV.Read_Result resultRead = await ws_Vendor.ReadAsync(VendorNo);

                WSVendorNAV.Delete_Result result = await ws_Vendor.DeleteAsync(resultRead.WSVendor.Key);

                return(result);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public static async Task <FornecedorDetailsViewModel> GetByNoAsync(string VendorNo, NAVWSConfigurations WSConfigurations)
        {
            if (VendorNo == null)
            {
                throw new ArgumentNullException("VendorNo");
            }

            //Configure NAV Vendor
            EndpointAddress WS_URL = new EndpointAddress(WSConfigurations.WS_Vendor_URL.Replace("Company", WSConfigurations.WS_User_Company));

            WSVendorNAV.WSVendor_PortClient WS_Vendor = new WSVendorNAV.WSVendor_PortClient(navWSBinding, WS_URL);
            WS_Vendor.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Delegation;
            WS_Vendor.ClientCredentials.Windows.ClientCredential          = new NetworkCredential(WSConfigurations.WS_User_Login, WSConfigurations.WS_User_Password, WSConfigurations.WS_User_Domain);

            try
            {
                WSVendorNAV.Read_Result result = await WS_Vendor.ReadAsync(VendorNo);

                var WSVendor = result.WSVendor;

                var vendor = MapVendorNAVToVendorModel(WSVendor);
                return(vendor);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public static async Task <WSVendorNAV.Update_Result> UpdateAsync(FornecedorDetailsViewModel vendor, NAVWSConfigurations WSConfigurations)
        {
            if (vendor == null)
            {
                throw new ArgumentNullException("vendor");
            }


            WSVendorNAV.Update navUpdate = new WSVendorNAV.Update()
            {
                WSVendor = MapVendorModelToVendorNAV(vendor)
            };

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

            WSVendorNAV.WSVendor_PortClient ws_Vendor = new WSVendorNAV.WSVendor_PortClient(navWSBinding, ws_URL);
            ws_Vendor.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Delegation;
            ws_Vendor.ClientCredentials.Windows.ClientCredential          = new NetworkCredential(WSConfigurations.WS_User_Login, WSConfigurations.WS_User_Password, WSConfigurations.WS_User_Domain);

            WSVendorNAV.Read_Result resultRead = await ws_Vendor.ReadAsync(navUpdate.WSVendor.No);

            navUpdate.WSVendor.Key = resultRead.WSVendor.Key;

            try
            {
                navUpdate.WSVendor.Utilizador_Alteracao_eSUCH = vendor.Utilizador_Alteracao_eSUCH;

                navUpdate.WSVendor.BlockedSpecified = true;
                navUpdate.WSVendor.Bloqueado_Falta_PagamentoSpecified = true;
                navUpdate.WSVendor.Bloqueado_UrgenteSpecified         = true;
                navUpdate.WSVendor.CertificaçãoSpecified      = true;
                navUpdate.WSVendor.ClassificaçãoSpecified     = true;
                navUpdate.WSVendor.CriticidadeSpecified       = true;
                navUpdate.WSVendor.Interface_ComprasSpecified = true;
                navUpdate.WSVendor.PontuaçãoSpecified         = true;
                navUpdate.WSVendor.PreferencialSpecified      = true;

                WSVendorNAV.Update_Result result = await ws_Vendor.UpdateAsync(navUpdate);

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