Exemplo n.º 1
0
        public async Task <ActionResult <HttpResultModel> > GetAll()
        {
            HttpResultModel httpResult = new HttpResultModel();

            try
            {
                VRTSoapService.vrtserviceRD3SoapClient            service        = new VRTSoapService.vrtserviceRD3SoapClient();
                ChannelFactory <VRTSoapService.vrtserviceRD3Soap> channelFactory = service.ChannelFactory;
                VRTSoapService.vrtserviceRD3Soap channel = channelFactory.CreateChannel();

                VRTSoapService.ServiceRequest serviceRequest = new VRTSoapService.ServiceRequest
                {
                    Body = new VRTSoapService.ServiceRequestBody
                    {
                        username         = soapUsername,
                        password         = soapPassword,
                        ShopName         = "",
                        BusinessTypeCode = "",
                        ProvinceCode     = 0,
                        StreetCode       = 0
                    }
                };

                VRTSoapService.ServiceResponse responseMessage = await channel.ServiceAsync(serviceRequest);

                VRTSoapService.vrt soapResult = responseMessage?.Body?.ServiceResult;
                List <VRT>         listVRT    = new List <VRT>();

                if (soapResult != null)
                {
                    int countRecord = soapResult.vShopName.Count();

                    for (int index = 0; index < countRecord; index++)
                    {
                        VRT vrtModel = new VRT
                        {
                            vShopName         = soapResult.vShopName[index]?.ToString(),
                            vBusinessTypeName = soapResult.vBusinessTypeName[index]?.ToString(),
                            vBusinessName     = soapResult.vBusinessName[index]?.ToString(),
                            vHouseNumber      = soapResult.vHouseNumber[index]?.ToString(),
                            vStreetName       = soapResult.vStreetName[index]?.ToString(),
                            vThambolName      = soapResult.vThambolName[index]?.ToString(),
                            vAmphurName       = soapResult.vAmphurName[index]?.ToString(),
                            vProvinceName     = soapResult.vProvinceName[index]?.ToString(),
                            vPostCode         = soapResult.vPostCode[index]?.ToString(),
                            vmsgerr           = soapResult.vmsgerr.Count() > 0 ? soapResult.vmsgerr[index]?.ToString() : null,
                        };
                        listVRT.Add(vrtModel);
                    }
                }

                httpResult.SetPropertyHttpResult(httpResult, true, "", "", StatusCodes.Status200OK, listVRT);
            }
            catch (Exception ex)
            {
                httpResult.SetPropertyHttpResult(httpResult, false, "", ex.Message, StatusCodes.Status500InternalServerError);
            }

            return(httpResult);
        }
Exemplo n.º 2
0
 public ServiceResponseBody(VRTSoapService.vrt ServiceResult)
 {
     this.ServiceResult = ServiceResult;
 }