Beispiel #1
0
        public ActionResult <List <AddressReturn> > CheckManyAddresses([FromBody] List <AddressInfo> addresssList)
        {
            try
            {
                var addressProcessing = new AddressProcessing(Configuration["Smarty:userName"], Configuration["Smarty:password"]);
                var returnList        = new ConcurrentBag <AddressReturn>();
                Parallel.ForEach(addresssList, (address) =>
                {
                    var addAddress = new AddressReturn();
                    try
                    {
                        addAddress = addressProcessing.ProcessAddress(address);
                    }
                    catch (Exception e)
                    {
                        addAddress.ValidAddress = false;
                        addAddress.errorMessage = e.Message;
                    }
                    returnList.Add(addAddress);
                });

                return(StatusCode(200, returnList));
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }
Beispiel #2
0
        public ActionResult <AddressReturn> CheckValidAddress(string address1, string address2, string city, string state, string zip)
        {
            try
            {
                var address = new AddressInfo
                {
                    Address1 = address1,
                    Address2 = address2,
                    City     = city,
                    State    = state,
                    Zip      = zip
                };

                var addressProcessing = new AddressProcessing(Configuration["Smarty:userName"], Configuration["Smarty:password"]);
                return(StatusCode(200, addressProcessing.ProcessAddress(address)));
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }