Esempio n. 1
0
        public ActionResult GetLocalAreaByStateId(int stateId)
        {
            try
            {
                var add   = new KeyContent(0, "Select a Local Government");
                var items = CustomManager.GetLocalAreaByStateId(stateId);

                //var items = new List<LocalArea>
                //{
                //    new LocalArea
                //    {
                //        LocalAreaId = 1,
                //        Name = "Ogba/Egbema/Ndoni"
                //    },
                //    new LocalArea
                //    {
                //        LocalAreaId = 2,
                //        Name = "Omumma"
                //    },
                //};

                if (!items.Any())
                {
                    return(Json(new List <KeyContent> {
                        add
                    }, JsonRequestBehavior.AllowGet));
                }
                var jsonitem = items.Select(o => new KeyContent(o.LocalAreaId, o.Name)).ToList();
                jsonitem.Insert(0, add);
                return(Json(jsonitem, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                BugManager.LogApplicationBug(ex.StackTrace, ex.Source, ex.Message);
                return(Json(new List <KeyContent>(), JsonRequestBehavior.AllowGet));
            }
        }