//tour1.2
        public async Task <IGRPTrafficInfo_result> IGRPTrafficInfo_api(IGRPTrafficInfo_PostData postdata)
        {
            string     targetURI = "https://dtour-api.startravel.com.tw/api/IGRPTrafficInfo";
            string     final_URI = targetURI + "?prod_no=" + postdata.prod_no + "&grp_no=" + postdata.grp_no;
            HttpClient client    = new HttpClient();

            client.MaxResponseContentBufferSize = Int32.MaxValue;

            HttpResponseMessage response = client.GetAsync(final_URI).Result;
            var collection      = response.Content.ReadAsStringAsync().Result;
            var collection_jobj = JsonConvert.DeserializeObject <IGRPTrafficInfo_result>(collection);

            return(collection_jobj);
        }
        public async Task <ActionResult> Index(detail_view_return_data data)
        {
            ApiController api          = new ApiController();
            string        view_prod_no = data.grpproductdetail_result.Data.PROD_NO;
            string        view_grp_no  = data.grpproductdetail_result.Data.GRP_NO;
            //string view_prod_no = "IGRP000018191";
            //string view_grp_no = "OKA04IT31617T";

            //***GRPProductDetail_api testing***//

            GRPProductDetail_PostData grpproductdetail_postData = new GRPProductDetail_PostData()
            {
                prod_no = view_prod_no, grp_no = view_grp_no
            };
            IGRPTrafficInfo_PostData igrptrafficinfo_postData = new IGRPTrafficInfo_PostData()
            {
                prod_no = view_prod_no, grp_no = view_grp_no
            };
            GRPPriceInfo_PostData grppriceinfo_postData = new GRPPriceInfo_PostData()
            {
                prod_no = view_prod_no, grp_no = view_grp_no
            };



            var grpsource = await api.GRPProductDetail_api(grpproductdetail_postData);

            var igrptrafficinfo_source = await api.IGRPTrafficInfo_api(igrptrafficinfo_postData);

            var grppriceinfo_source = await api.GRPPriceInfo_api(grppriceinfo_postData);

            // Response.Write("PROD_NAME:" + grpsource.Data.PROD_DESC3+ "<br/>");
            // JObject grpsource_ob =await grpsource;
            step1_view_return_data step1_view_data = new step1_view_return_data {
                grpproductdetail_result = grpsource, igrptrafficinfo_result = igrptrafficinfo_source, grppriceinfo_result = grppriceinfo_source
            };



            return(View(step1_view_data));
        }
        public async Task <ActionResult> Index(step1_view_return_data data, string user_name, string user_passwd, string room_count_name)
        {
            string view_prod_no = data.grpproductdetail_result.Data.PROD_NO;
            string view_grp_no  = data.grpproductdetail_result.Data.GRP_NO;



            // return RedirectToAction("Index", "Step2", new { member_number = member_number, room_count_name = room_count_name, view_prod_no = view_prod_no, view_grp_no = view_grp_no });
            ApiController api = new ApiController();

            if (string.IsNullOrWhiteSpace(user_name) || string.IsNullOrWhiteSpace(user_passwd))
            {
                TempData["message"] = "身分證字號或密碼為空";
                return(RedirectToAction("Index", "Step1", new { prod_no = view_prod_no, grp_no = view_grp_no }));
            }
            else
            {
                LoginVerify_PostData loginverify_postData = new LoginVerify_PostData()
                {
                    ID_NO = user_name, password = user_passwd
                };
                var loginverify_source = await api.LoginVerify_api(loginverify_postData);

                // Response.Write("loginverify_source.rCode:" + loginverify_source.rCode + "<br/>");

                if (loginverify_source.rCode.Equals("0001"))
                {
                    string member_number = loginverify_source.Data.MEMBER_NO;
                    TempData["message"] = "登入成功";
                    string member_number_s   = member_number;
                    string view_prod_no_s    = view_prod_no;
                    string view_grp_no_s     = view_grp_no;
                    string room_count_name_s = room_count_name;

                    string[] psub_list  = new string[7];
                    string[] visa_list  = new string[7];
                    string[] insu_list  = new string[7];
                    int      pusb_count = 0;
                    int      visa_count = 0;
                    int      insu_count = 0;


                    // ApiController api = new ApiController();
                    GRPProductDetail_PostData grpproductdetail_postData = new GRPProductDetail_PostData()
                    {
                        prod_no = view_prod_no_s, grp_no = view_grp_no_s
                    };
                    IGRPTrafficInfo_PostData igrptrafficinfo_postData = new IGRPTrafficInfo_PostData()
                    {
                        prod_no = view_prod_no_s, grp_no = view_grp_no_s
                    };
                    GRPPriceInfo_PostData grppriceinfo_postData = new GRPPriceInfo_PostData()
                    {
                        prod_no = view_prod_no_s, grp_no = view_grp_no_s
                    };
                    PassengerContacts_get_PostData passengercontacts_postData = new PassengerContacts_get_PostData()
                    {
                        member_no = member_number_s
                    };
                    GRPAddPurchase_PostData grpaddpurchase_postData = new GRPAddPurchase_PostData()
                    {
                        prod_no = view_prod_no_s, grp_no = view_grp_no_s
                    };


                    var grpsource = await api.GRPProductDetail_api(grpproductdetail_postData);

                    var igrptrafficinfo_source = await api.IGRPTrafficInfo_api(igrptrafficinfo_postData);

                    var grppriceinfo_source = await api.GRPPriceInfo_api(grppriceinfo_postData);

                    //var passengercontacts_source = await api.PassengerContacts_get_api(passengercontacts_postData);
                    var passengercontacts_source = await api.PassengerContacts_get_api(passengercontacts_postData);

                    var grpaddpurchase_source = await api.GRPAddPurchase_api(grpaddpurchase_postData);

                    // Response.Write("0:" + passengercontacts_source + "<br/>");
                    var orderstore_source = await api.OrderStore_api();


                    for (int i = 0; i < grpaddpurchase_source.Data.Count; i = i + 1)
                    {
                        var    item     = grpaddpurchase_source.Data[i];
                        string name_num = item.prod_SUB_NO.Substring(0, 4);
                        if (name_num.Equals("VISA"))
                        {
                            visa_list[visa_count] = i.ToString();
                            visa_count            = visa_count + 1;
                        }
                        else if (name_num.Equals("PSUB"))
                        {
                            psub_list[pusb_count] = i.ToString();
                            pusb_count            = pusb_count + 1;
                        }
                        else if (name_num.Equals("INSU"))
                        {
                            insu_list[insu_count] = i.ToString();
                            insu_count            = insu_count + 1;
                        }
                    }

                    step2_view_return_data step2_view_data = new step2_view_return_data
                    {
                        grpproductdetail_result = grpsource,
                        igrptrafficinfo_result  = igrptrafficinfo_source,
                        grppriceinfo_result     = grppriceinfo_source,
                        room_count                   = room_count_name_s,
                        grpaddpurchase_result        = grpaddpurchase_source,
                        passengercontacts_get_result = passengercontacts_source,
                        orderstore_result            = orderstore_source,
                        visa_list  = visa_list,
                        psub_list  = psub_list,
                        insu_list  = insu_list,
                        visa_count = visa_count,
                        pusb_count = pusb_count,
                        insu_count = insu_count
                    };


                    //=====build passenget list item
                    List <SelectListItem> passenget_item = new List <SelectListItem>();
                    for (int j = 0; j < passengercontacts_source.Data.Count; j = j + 1)
                    {
                        var    item       = passengercontacts_source.Data[j];
                        string birthday_s = item.BIRTHDAY;
                        if (!(birthday_s == null))
                        {
                            DateTime p_birthday_s = DateTime.ParseExact(item.BIRTHDAY.ToString(), "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
                            item.BIRTHDAY = p_birthday_s.ToString("yyyy/MM/dd");
                        }


                        //Response.Write(j.ToString() + ": " + item.BIRTHDAY + "<br/>");
                        passenget_item.Add(new SelectListItem()
                        {
                            Text  = item.NAME_C_FIRST + item.NAME_C_LAST,
                            Value = j.ToString()
                        });

                        //var item = passengercontacts_source.Data[j];
                        //Response.Write(j.ToString() + ": " + item.ID_NO + "<br/>");
                    }


                    ViewBag.CategoryItems = passenget_item;

                    //=====build passenget list item

                    //=====build stroe list item
                    List <SelectListItem> store_item = new List <SelectListItem>();
                    for (int k = 0; k < orderstore_source.Data.Count; k = k + 1)
                    {
                        var item = orderstore_source.Data[k];


                        //Response.Write(j.ToString() + ": " + item.BIRTHDAY + "<br/>");
                        store_item.Add(new SelectListItem()
                        {
                            Text  = item.Dept_Region + "   " + item.Dept_Name,
                            Value = k.ToString()
                        });
                    }

                    ViewBag.Selectstore = store_item;
                    /*string[] strs = room_count_name.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);*/

                    /*  for (int j = 0; j < passengercontacts_source.Data.Count;j=j+1 )
                     * {
                     *    var item = passengercontacts_source.Data[j];
                     *    Response.Write(j.ToString() + ": " + item.ID_NO + "<br/>");
                     * }*/

                    // Response.Write("1:" + passengercontacts_source.Data[1].ID_NO + "<br/>");
                    //Response.Write("2:" + passengercontacts_source.Data[2].ID_NO + "<br/>");
                    // Response.Write("3:" + passengercontacts_source.Data[3].ID_NO + "<br/>");
                    // Response.Write("4:" + passengercontacts_source.Data[4].ID_NO + "<br/>");
                    //  Response.Write("5:" + passengercontacts_source.Data[5].ID_NO + "<br/>");
                    // room_count_name.Split
                    return(View(step2_view_data));

                    // return RedirectToAction("Index", "Step2", new { view_prod_no = view_prod_no, view_grp_no = view_grp_no, room_count_name = room_count_name, member_number = member_number });
                }
                else
                {
                    TempData["message"] = "帳號或密碼輸入錯誤";
                    return(RedirectToAction("Index", "Step1", new { prod_no = view_prod_no, grp_no = view_grp_no }));
                }
            }
        }
        //
        // GET: /Step2/
        public async Task <ActionResult> Index(string member_number, string room_count_name, string view_grp_no, string view_prod_no)
        {
            // Response.Write("user_name:" + user_name + "<br/>");

            /* Response.Write("member_number:" + member_number + "<br/>");
             * Response.Write("view_grp_no:" + view_grp_no + "<br/>");
             * Response.Write("view_prod_no:" + view_prod_no + "<br/>");
             * Response.Write("room_count_name:" + room_count_name + "<br/>");*/

            /*string member_number_s = member_number;
             * string view_prod_no_s = view_prod_no;
             * string view_grp_no_s = view_grp_no;
             * string room_count_name_s = room_count_name;*/


            string member_number_s   = "MEM0000000028";
            string view_prod_no_s    = "IGRP000017364";
            string view_grp_no_s     = "OKA04ITC1417A";
            string room_count_name_s = "1,1,0,0,0";

            string[] psub_list  = new string[7];
            string[] visa_list  = new string[7];
            string[] insu_list  = new string[7];
            int      pusb_count = 0;
            int      visa_count = 0;
            int      insu_count = 0;


            ApiController             api = new ApiController();
            GRPProductDetail_PostData grpproductdetail_postData = new GRPProductDetail_PostData()
            {
                prod_no = view_prod_no_s, grp_no = view_grp_no_s
            };
            IGRPTrafficInfo_PostData igrptrafficinfo_postData = new IGRPTrafficInfo_PostData()
            {
                prod_no = view_prod_no_s, grp_no = view_grp_no_s
            };
            GRPPriceInfo_PostData grppriceinfo_postData = new GRPPriceInfo_PostData()
            {
                prod_no = view_prod_no_s, grp_no = view_grp_no_s
            };
            PassengerContacts_get_PostData passengercontacts_postData = new PassengerContacts_get_PostData()
            {
                member_no = member_number_s
            };
            GRPAddPurchase_PostData grpaddpurchase_postData = new GRPAddPurchase_PostData()
            {
                prod_no = view_prod_no_s, grp_no = view_grp_no_s
            };


            var grpsource = await api.GRPProductDetail_api(grpproductdetail_postData);

            var igrptrafficinfo_source = await api.IGRPTrafficInfo_api(igrptrafficinfo_postData);

            var grppriceinfo_source = await api.GRPPriceInfo_api(grppriceinfo_postData);

            //var passengercontacts_source = await api.PassengerContacts_get_api(passengercontacts_postData);
            var passengercontacts_source = await api.PassengerContacts_get_api(passengercontacts_postData);

            var grpaddpurchase_source = await api.GRPAddPurchase_api(grpaddpurchase_postData);

            // Response.Write("0:" + passengercontacts_source + "<br/>");
            var orderstore_source = await api.OrderStore_api();


            for (int i = 0; i < grpaddpurchase_source.Data.Count; i = i + 1)
            {
                var    item     = grpaddpurchase_source.Data[i];
                string name_num = item.prod_SUB_NO.Substring(0, 4);
                if (name_num.Equals("VISA"))
                {
                    visa_list[visa_count] = i.ToString();
                    visa_count            = visa_count + 1;
                }
                else if (name_num.Equals("PSUB"))
                {
                    psub_list[pusb_count] = i.ToString();
                    pusb_count            = pusb_count + 1;
                }
                else if (name_num.Equals("INSU"))
                {
                    insu_list[insu_count] = i.ToString();
                    insu_count            = insu_count + 1;
                }
            }

            step2_view_return_data step2_view_data = new step2_view_return_data {
                grpproductdetail_result = grpsource,
                igrptrafficinfo_result  = igrptrafficinfo_source,
                grppriceinfo_result     = grppriceinfo_source,
                room_count                   = room_count_name_s,
                grpaddpurchase_result        = grpaddpurchase_source,
                passengercontacts_get_result = passengercontacts_source,
                orderstore_result            = orderstore_source,
                visa_list  = visa_list,
                psub_list  = psub_list,
                insu_list  = insu_list,
                visa_count = visa_count,
                pusb_count = pusb_count,
                insu_count = insu_count
            };


            //=====build passenget list item
            List <SelectListItem> passenget_item = new  List <SelectListItem>();

            for (int j = 0; j < passengercontacts_source.Data.Count; j = j + 1)
            {
                var    item       = passengercontacts_source.Data[j];
                string birthday_s = item.BIRTHDAY;
                if (!(birthday_s == null))
                {
                    DateTime p_birthday_s = DateTime.ParseExact(item.BIRTHDAY.ToString(), "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
                    item.BIRTHDAY = p_birthday_s.ToString("yyyy/MM/dd");
                }


                //Response.Write(j.ToString() + ": " + item.BIRTHDAY + "<br/>");
                passenget_item.Add(new SelectListItem()
                {
                    Text  = item.NAME_C_FIRST + item.NAME_C_LAST,
                    Value = j.ToString()
                });

                //var item = passengercontacts_source.Data[j];
                //Response.Write(j.ToString() + ": " + item.ID_NO + "<br/>");
            }


            ViewBag.CategoryItems = passenget_item;

            //=====build passenget list item

            //=====build stroe list item
            List <SelectListItem> store_item = new List <SelectListItem>();

            for (int k = 0; k < orderstore_source.Data.Count; k = k + 1)
            {
                var item = orderstore_source.Data[k];


                //Response.Write(j.ToString() + ": " + item.BIRTHDAY + "<br/>");
                store_item.Add(new SelectListItem()
                {
                    Text  = item.Dept_Region + "   " + item.Dept_Name,
                    Value = k.ToString()
                });
            }

            ViewBag.Selectstore = store_item;
            /*string[] strs = room_count_name.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);*/

            /*  for (int j = 0; j < passengercontacts_source.Data.Count;j=j+1 )
             * {
             *    var item = passengercontacts_source.Data[j];
             *    Response.Write(j.ToString() + ": " + item.ID_NO + "<br/>");
             * }*/

            // Response.Write("1:" + passengercontacts_source.Data[1].ID_NO + "<br/>");
            //Response.Write("2:" + passengercontacts_source.Data[2].ID_NO + "<br/>");
            // Response.Write("3:" + passengercontacts_source.Data[3].ID_NO + "<br/>");
            // Response.Write("4:" + passengercontacts_source.Data[4].ID_NO + "<br/>");
            //  Response.Write("5:" + passengercontacts_source.Data[5].ID_NO + "<br/>");
            // room_count_name.Split
            return(View(step2_view_data));
        }