You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
110 lines
3.3 KiB
110 lines
3.3 KiB
using Business.api.addressy;
|
|
using Common;
|
|
using Common.Model;
|
|
using Common.Model.Addressy;
|
|
using log4net;
|
|
using Repository;
|
|
using Repository.Mobile;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Business.Addressy
|
|
{
|
|
|
|
public class LocateBusiness
|
|
{
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(LocateBusiness));
|
|
|
|
ServiceApi serviceApi { get; set; }
|
|
public LocateBusiness()
|
|
{
|
|
serviceApi = new ServiceApi();
|
|
|
|
|
|
}
|
|
|
|
public JsonRxResponse QueryAddress(string postCode)
|
|
|
|
{
|
|
JsonRxResponse rxResponse = new JsonRxResponse() { ErrorCode = "1", Msg = "No Data found" };
|
|
var results = serviceApi.Find_v1_10(postCode);
|
|
|
|
Log.Debug(Newtonsoft.Json.JsonConvert.SerializeObject(results));
|
|
|
|
if (results != null && results.Any())
|
|
{
|
|
var single = results.FirstOrDefault();
|
|
if (single != null && single.Type.Equals("Postcode"))
|
|
{
|
|
rxResponse.ErrorCode = "0";
|
|
rxResponse.Msg = "Post code found";
|
|
|
|
var result2 = serviceApi.Find_v1_10(postCode, single.Id);
|
|
|
|
QueryResponse queryResponsse = new QueryResponse();
|
|
|
|
queryResponsse.Addresses = new List<Address>();
|
|
foreach (Capture_Interactive_Find_v1_10_Results item in result2)
|
|
{
|
|
queryResponsse.Addresses.Add(new Address()
|
|
{
|
|
Id = item.Id,
|
|
Type = item.Type,
|
|
Address1 = item.Text,
|
|
City = item.Description.Substring(0, item.Description.LastIndexOf(","))
|
|
});
|
|
}
|
|
|
|
|
|
rxResponse.Data = queryResponsse;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
rxResponse.Msg = "No result!";
|
|
}
|
|
|
|
return rxResponse;
|
|
}
|
|
|
|
|
|
public QueryResponse LoadKycStaticData()
|
|
{
|
|
QueryResponse queryResponse = new QueryResponse();
|
|
var sql = "EXEC proc_mobile_StaticData @flag='Query-Address'";
|
|
|
|
Dao _dao = new Dao();
|
|
var ds = _dao.ExecuteDataset(sql);
|
|
|
|
if (ds.Tables.Count == 2)
|
|
{
|
|
var nativeCountry = ds.Tables[0];
|
|
var ncr = from nc in nativeCountry.AsEnumerable()
|
|
select new NativeCountry
|
|
{
|
|
id = nc.Field<int>("id").ToString(),
|
|
text = nc.Field<string>("text"),
|
|
code = nc.Field<string>("Code")
|
|
};
|
|
queryResponse.NativeCountry = ncr.ToList();
|
|
|
|
var gender = ds.Tables[1];
|
|
var g = from gd in gender.AsEnumerable()
|
|
select new Gender
|
|
{
|
|
id = gd.Field<int>("id").ToString(),
|
|
text = gd.Field<string>("text"),
|
|
|
|
};
|
|
queryResponse.Gender = g.ToList();
|
|
|
|
}
|
|
|
|
return queryResponse;
|
|
}
|
|
}
|
|
}
|