public ActionResult GetRoles() { try { var add = new KeyContent(0, "Select a Role"); var items = CustomManager.GetRoles(); if (items == null || !items.Any()) { return(Json(new List <KeyContent> { add }, JsonRequestBehavior.AllowGet)); } var jsonitem = items.Select(o => new KeyContent(o.RoleId, 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)); } }