예제 #1
0
        /// <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));
        }
예제 #2
0
        /// <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));
        }