public JsonResult MultiLabelQuery(string ShopUrl, string Address1, string Address2, string Suburb, string Postcode, float Weight, string Instruction, string Type)
        {
            //DB connection to query store details
            DbEngine newDB = new DbEngine();
            //get store details with provided url
            StoreRecord storeDetails = newDB.GetShopRecord(ShopUrl);
            //Labeldetails entity to query
            Labeldetails label = new Labeldetails();

            //populate store details for query
            label.apiKey       = storeDetails.FastwayApiKey;
            label.fromAddress1 = storeDetails.StoreAddress1;
            label.fromCity     = storeDetails.Suburb;
            label.fromPostcode = storeDetails.Postcode;
            //populate delivery details for query
            label.toAddress1 = Address1;
            label.toAddress2 = Address2;
            label.toCity     = Suburb;
            label.toPostcode = Postcode;
            //populate parcel details for query
            label.weight      = (double)Weight;
            label.countryCode = storeDetails.CountryCode;

            List <string> labelNumbers = new List <string>();
            string        destRF       = "";

            try
            {
                if (Type != "Parcel")
                {
                    if (Weight > 5)
                    {
                        labelNumbers.Add("No Service Found");
                    }
                    else
                    {
                        label.specialInstruction1 = Instruction;

                        //new fastwayAPI object to query
                        FastwayAPI getLabel = new FastwayAPI();
                        //get label with V2 method
                        Labeldetails l = new Labeldetails();

                        if (Type == "SAT-NAT-A3")
                        {
                            List <UsableLabel> services = getLabel.ServiceQuery(label);
                            if (services.First().BaseLabelColour == "BROWN")
                            {
                                label.labelColour = services[services.FindIndex(a => a.BaseLabelColour == "SAT-LOC-A3")].BaseLabelColour;
                            }
                            else
                            {
                                label.labelColour = Type;
                            }
                        }
                        else
                        {
                            label.labelColour = Type;
                        }
                        l = getLabel.LabelQueryV2(label);
                        labelNumbers.Add(l.labelNumber);
                        labelNumbers.Add(l.ruralNumber);
                        destRF = l.toRfName;
                    }
                }
                else
                {
                    //new fastwayAPI object to query
                    FastwayAPI getLabel = new FastwayAPI();
                    //get label with V2 method
                    Labeldetails       l        = new Labeldetails();
                    List <UsableLabel> services = getLabel.ServiceQuery(label);
                    label.labelColour = services.First().BaseLabelColour;
                    l = getLabel.LabelQueryV2(label);
                    labelNumbers.Add(l.labelNumber);
                    labelNumbers.Add(l.ruralNumber);
                    destRF = l.toRfName;
                }
            }
            catch (Exception)
            {
                labelNumbers.Add("No Service Found");
            }
            return(Json(new
            {//return details about availabel service
                BaseLabel = labelNumbers[0],
                RuralLabel = labelNumbers[1],
                Service = label.labelColour,
                DestRF = destRF
            }));
        }
        public JsonResult LabelQuery(string ShopUrl, string Address1, string Address2, string Suburb, string Postcode, string Region, float Weight, string Type)
        {
            //DB connection to query store details
            DbEngine newDB = new DbEngine();
            //get store details with provided url
            StoreRecord storeDetails = newDB.GetShopRecord(ShopUrl);
            //Labeldetails entity to query
            Labeldetails label = new Labeldetails();

            //populate store details for query
            label.apiKey       = storeDetails.FastwayApiKey;
            label.fromAddress1 = storeDetails.StoreAddress1;
            label.fromCity     = storeDetails.Suburb;
            label.fromPostcode = storeDetails.Postcode;
            //populate delivery details for query
            label.toAddress1 = Address1;
            label.toAddress2 = Address2;
            label.toCity     = Suburb;
            label.toPostcode = Postcode;
            //populate parcel details for query
            label.weight      = (double)Weight;
            label.countryCode = storeDetails.CountryCode;
            //FastwayAPI object for service query
            FastwayAPI newApiCall = new FastwayAPI();
            //Call fastway API and receive back a list of available service
            List <UsableLabel> services = newApiCall.ServiceQuery(label);
            //UsableLabel entity to respond
            UsableLabel service = new UsableLabel();

            try
            {
                if (services.First().CostexgstTotalChargeToEndUser != 0)
                {         //if no service found
                    if (services.Count == 1 && Type != "Parcel")
                    {     //no service and type was "Parcel"
                        return(Json(new
                        { //return an Error code
                            Error = "No Service Available"
                        }));
                    }
                    else//service(s) available
                    {
                        if (Type == "Parcel")
                        {//type was "Parcel", assign parcel option to response json
                            service = services.First();
                        }
                        else
                        {//type was NOT "Parcel", get service based on value of Type
                            if (Type == "SAT-NAT-A3")
                            {
                                if (services.First().BaseLabelColour == "BROWN")
                                {
                                    service = services[services.FindIndex(a => a.BaseLabelColour == "SAT-LOC-A3")];
                                }
                                else
                                {
                                    service = services[services.FindIndex(a => a.BaseLabelColour == Type)];
                                }
                            }
                            else
                            {
                                service = services[services.FindIndex(a => a.BaseLabelColour == Type)];
                            }
                        }
                        return(Json(new
                        {//return details about availabel service
                            BaseLabelColour = service.BaseLabelColour,
                            TotalCost = service.CostexgstTotalChargeToEndUser,
                            Rural = service.RuralLabelCostExgst > 0 ? true : false,
                            Excess = service.ExcessLabelCount,
                            Saturday = services.First().Saturday
                        }));
                    }
                }
                else
                {
                    return(Json(new
                    {//Error code from Fastway NOTE: will need to handle different type of error HERE
                        Error = "No Service Available"
                    }));
                }
            }
            catch (Exception e)
            {
                //general error code Note: will need to handle these
                throw e;
            }
        }