public Common(CommonSoapService.common soapObject) { if (soapObject != null) { vBusinessTypeCode = soapObject.vBusinessTypeCode?.FirstOrDefault()?.ToString(); vBusinessTypeName = soapObject.vBusinessTypeName?.FirstOrDefault()?.ToString(); vStreetCode = soapObject.vStreetCode?.FirstOrDefault()?.ToString(); vStreetName = soapObject.vStreetName?.FirstOrDefault()?.ToString(); vVRTProvinceCode = soapObject.vVRTProvinceCode?.FirstOrDefault()?.ToString(); vVRTProvinceName = soapObject.vVRTProvinceName?.FirstOrDefault()?.ToString(); vAmphurCode = soapObject.vAmphurCode?.FirstOrDefault()?.ToString(); vProvinceCode = soapObject.vProvinceCode?.FirstOrDefault()?.ToString(); vDescription = soapObject.vDescription?.FirstOrDefault()?.ToString(); vMessErr = soapObject.vMessErr?.FirstOrDefault()?.ToString(); } }
public ServiceResponseBody(CommonSoapService.common ServiceResult) { this.ServiceResult = ServiceResult; }
public async Task <ActionResult <HttpResultModel> > Get(string typeOfService) { HttpResultModel httpResult = new HttpResultModel(); try { CommonSoapService.commonserviceRD3SoapClient service = new CommonSoapService.commonserviceRD3SoapClient(); ChannelFactory <CommonSoapService.commonserviceRD3Soap> channelFactory = service.ChannelFactory; CommonSoapService.commonserviceRD3Soap channel = channelFactory.CreateChannel(); CommonSoapService.ServiceRequest serviceRequest = new CommonSoapService.ServiceRequest { Body = new CommonSoapService.ServiceRequestBody { username = soapUsername, password = soapPassword, typeofservice = typeOfService } }; CommonSoapService.ServiceResponse responseMessage = await channel.ServiceAsync(serviceRequest); CommonSoapService.common soapResult = responseMessage?.Body.ServiceResult; List <Common> listCommon = new List <Common>(); Model.Common commonModel = new Model.Common(soapResult); if (soapResult != null) { int countRecord = 0; if (typeOfService == VRTCommonService) { countRecord = soapResult.vBusinessTypeCode.Count(); } else if (typeOfService == VATCommonService) { countRecord = soapResult.vAmphurCode.Count(); } for (int index = 0; index < countRecord; index++) { Common common = new Common(); if (typeOfService == VRTCommonService) { common = new Common { typeofservice = typeOfService, // VRTCommon vBusinessTypeCode = soapResult.vBusinessTypeCode[index]?.ToString(), vBusinessTypeName = soapResult.vBusinessTypeName[index]?.ToString(), vStreetCode = soapResult.vStreetCode[index]?.ToString(), vStreetName = soapResult.vStreetName[index]?.ToString(), vVRTProvinceCode = soapResult.vVRTProvinceCode[index]?.ToString(), vVRTProvinceName = soapResult.vVRTProvinceName[index]?.ToString(), vMessErr = soapResult.vMessErr.Count() > 0 ? soapResult.vMessErr[index]?.ToString() : null, }; listCommon.Add(common); } else if (typeOfService == VATCommonService) { common = new Common { typeofservice = typeOfService, // VATCommon vAmphurCode = soapResult.vAmphurCode[index]?.ToString(), vProvinceCode = soapResult.vProvinceCode[index]?.ToString(), vDescription = soapResult.vDescription[index]?.ToString(), vMessErr = soapResult.vMessErr.Count() > 0 ? soapResult.vMessErr[index]?.ToString() : null, }; listCommon.Add(common); } } } httpResult.SetPropertyHttpResult(httpResult, true, "", "", StatusCodes.Status200OK, listCommon); } catch (Exception ex) { httpResult.SetPropertyHttpResult(httpResult, false, "API Error", ex.Message, StatusCodes.Status500InternalServerError); } return(Ok(httpResult)); }