Пример #1
0
 public ActionResult Index(UserData data)
 {
     if (string.IsNullOrWhiteSpace(data.password1) || data.password1 != data.password2)
     {
         List <City>    cityList    = db.GetCityList();
         List <Village> villageList = new List <Village>();
         if (!string.IsNullOrWhiteSpace(data.city))
         {
             villageList = db.GetVillageList(data.city);
         }
         ViewBag.CityList    = cityList;
         ViewBag.VillageList = villageList;
         ViewBag.Msg         = "密碼輸入錯誤";
         return(View(data));
     }
     else
     {
         if (db.AddUserData(data))
         {
             Response.Redirect("~/Login/Login");
             return(new EmptyResult());
         }
         else
         {
             List <City>    cityList    = db.GetCityList();
             List <Village> villageList = new List <Village>();
             if (!string.IsNullOrWhiteSpace(data.city))
             {
                 villageList = db.GetVillageList(data.city);
             }
             ViewBag.CityList    = cityList;
             ViewBag.VillageList = villageList;
             ViewBag.Msg         = "註冊失敗...";
             return(View(data));
         }
     }
 }