public JsonResult Get([FromBody] ClientDetailsViewModel data)
        {
            if (data != null && data.No != null && data.No != "")
            {
                var getShipToAddress = WSShipToAddressService.GetByNoAsync(data.No, _configws);
                try
                {
                    getShipToAddress.Wait();
                }
                catch (Exception ex)
                {
                    data.eReasonCode = 3;
                    data.eMessage    = "Ocorreu um erro a obter o endereço de envio no NAV.";
                    data.eMessages.Add(new TraceInformation(TraceType.Error, ex.Message));
                    return(Json(data));
                }

                var listShipToAddress = getShipToAddress.Result;
                if (listShipToAddress != null)
                {
                    return(Json(listShipToAddress));
                }
            }
            return(Json(false));
        }
        public JsonResult Update([FromBody] List <ShipToAddressViewModel> listData)
        {
            if (listData != null)
            {
                var retval      = new ErrorHandler();
                var Customer_No = "";
                foreach (var data in listData)
                {
                    Customer_No = data.Customer_No;
                    data.Utilizador_Alteracao_eSUCH = User.Identity.Name;
                    var updateTask = WSShipToAddressService.UpdateAsync(data, _configws);
                    try
                    {
                        updateTask.Wait();
                    }
                    catch (Exception ex)
                    {
                        retval.eReasonCode = 3;
                        retval.eMessage    = "Ocorreu um erro a actualizar a linha com o Código: \"" + data.Code.ToString() + "\"";
                        retval.eMessages.Add(new TraceInformation(TraceType.Error, ex.Message));

                        return(Json(retval));
                        //break; // get out of the loop
                    }
                }
                ;


                var getShipToAddress = WSShipToAddressService.GetByNoAsync(Customer_No, _configws);
                getShipToAddress.Wait();
                var listShipToAddress = getShipToAddress.Result;
                if (listShipToAddress != null)
                {
                    return(Json(listShipToAddress));
                }
            }
            return(Json(false));
        }