/// <summary> /// GET: List of ward by districtID /// </summary> /// <param name="districtID"></param> /// <returns></returns> public JsonResult WardListByDistrictID(int districtID) { var districtList = wardService.GetByDistrictID(districtID) .Select(x => new { ID = x.ID, Name = x.Name }).ToList(); return(Json(districtList, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Update ward combobox base on new districtID /// </summary> /// <param name="districtID"></param> /// <returns>Json</returns> public JsonResult UpdateWardList(int?districtID) { if (districtID.HasValue == false) { return(Json(null, JsonRequestBehavior.AllowGet)); } List <Ward> lstWard = wardService.GetByDistrictID(districtID.GetValueOrDefault(-1)).ToList(); if (lstWard == null) { return(Json(null, JsonRequestBehavior.AllowGet)); } return(this.Json(new { Result = (from obj in lstWard select new { ID = obj.ID, Name = obj.Name }) } , JsonRequestBehavior.AllowGet)); }