using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SampleScripts.Models;

namespace SampleScripts.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewBag.Message = "Welcome to ASP.NET MVC!";

            IList<Coutry> countryList = new List<Coutry>
                                        {
                                            new Coutry { CountryName = "Afganisthan", CountryCode="AF" },
                                            new Coutry { CountryName = "Australia", CountryCode="AU" },
                                            new Coutry { CountryName = "Brazil", CountryCode="BZ" },
                                            new Coutry { CountryName = "Ireland", CountryCode="IR" },
                                            new Coutry { CountryName = "India", CountryCode="IN" },
                                            new Coutry { CountryName = "United Kingdom", CountryCode="UK" },
                                            new Coutry { CountryName = "United States", CountryCode="US" },
                                        };

            IList<State> stateList = new List<State>
                                        {
                                            new State { StateName = "Alaska", StateCode="AL" },
                                            new State { StateName = "Arizona", StateCode="AR" },
                                            new State { StateName = "Colarado", StateCode="CO" },
                                            new State { StateName = "California", StateCode="CA" },
                                            new State { StateName = "Texas", StateCode="TX" },
                                            new State { StateName = "Minnesota", StateCode="MN" },
                                        };

            List<SelectListItem> selectCountryList = new List<SelectListItem>();
            selectCountryList.Add(new SelectListItem()
            {
                Value = "0",
                Text = "--Select--",
                Selected = true
            });
            foreach (var country in countryList)
            {
                selectCountryList.Add(new SelectListItem()
                    {
                       Value = country.CountryCode,
                       Text = country.CountryName
                    });
            }
            SelectList listOfCountries = new SelectList(selectCountryList,"Value", "Text", "US");

            List<SelectListItem> selectStatesList = new List<SelectListItem>();
            selectStatesList.Add(new SelectListItem()
            {
                Value = "0",
                Text = "--Select--",
                Selected = true
            });
            foreach (var state in stateList)
            {
                selectStatesList.Add(new SelectListItem()
                {
                    Value = state.StateCode,
                    Text = state.StateName
                });
            }
            SelectList listOfStates = new SelectList(selectStatesList, "Value", "Text", "CO");

            BasicInformationModel basicInformationModel = new BasicInformationModel();

            basicInformationModel.Country = listOfCountries;
            basicInformationModel.State = listOfStates;

            CustomerAddress address = new CustomerAddress
            { 
             
                City = "",
                CountryCode = "US",
                StateProvinceCode = "CO",
                Name = ""
            
            };

            CustomerAddresses addresses = new CustomerAddresses {
                BillingAddress = address,
                ShippingAddress = address
            };
            basicInformationModel.Address = addresses;
            basicInformationModel.BillingAddressSimilarToPrimary = false;
            return View(basicInformationModel);
        }

        public ActionResult About()
        {
            return View();
        }
    }
}
