public JsonResult GetAllLists() { //string LoginUser = (string)Session["LoginSAPID"]; try { string userkey = ConfigurationManager.AppSettings["userkey"]; string uid = ConfigurationManager.AppSettings["uid"]; TNS.TNS tns = new TNS.TNS(); DataTable dt = tns.FetchAllList("", userkey, uid); dt.TableName = "FetchLists"; dt.Columns.ToString(); var lists = (from DataRow dr in dt.Rows select new { ID = dr["ID"].ToString(), Listname = dr["Listname"].ToString(), Listtype = dr["Listtype"].ToString(), }).ToList(); return(Json(new { data = lists }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { //LogError logerror = new LogError(); //logerror.ErrorLog("", LoginUser, "", "Requests/GetRequestCategory", "Requests", "GetRequestCategory", "FetchRequestCategories Error", ex.Message.ToString(), 0); return(Json(new { data = "Error has occured" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Index() { string userkey = ConfigurationManager.AppSettings["userkey"]; string uid = ConfigurationManager.AppSettings["uid"]; TNS.TNS tns = new TNS.TNS(); DataTable dt = tns.FetchAllList("", userkey, uid); dt.TableName = "FetchList"; dt.Columns.ToString(); // var listCreated = tns.CreateListContent(LoginUser, "1", "OyeTunji", "Adelana", "*****@*****.**", "Stanbic IBTC", "Software Arc", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", userkey, uid); return(View()); }
public JsonResult GetLists([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel, String RequestId) { string userkey = ConfigurationManager.AppSettings["userkey"]; string uid = ConfigurationManager.AppSettings["uid"]; //string LoginUser = (string)Session["LoginSAPID"]; try { TNS.TNS tns = new TNS.TNS(); DataTable dt = tns.FetchAllList("", userkey, uid); dt.TableName = "FetchLists"; dt.Columns.ToString(); List <ContactLists> contactLists = new List <ContactLists>(); int startRec = requestModel.Start; int pageSize = requestModel.Length; List <ContactLists> listsCount = (from DataRow dr in dt.Rows select new ContactLists() { ID = dr["ID"].ToString() }).ToList(); contactLists = (from DataRow dr in dt.Rows orderby dr["ID"] descending select new ContactLists() { ID = dr["ID"].ToString(), Listname = dr["Listname"].ToString(), Datecreated = Convert.ToDateTime(dr["Datecreated"]).ToString("dd-MMM-yyyy hh:mm"), CreatedBy = dr["CreatedBy"].ToString() }).Skip(startRec).Take(pageSize).ToList(); var totalCount = listsCount.Count(); var filteredCount = contactLists.Count(); if (requestModel.Search.Value != string.Empty) { var value = requestModel.Search.Value.Trim(); listsCount = (from DataRow dr in dt.Rows where dr["Listname"].ToString().Contains(value) select new ContactLists() { ID = dr["ID"].ToString() }).ToList(); contactLists = (from DataRow dr in dt.Rows orderby dr["ID"] descending where dr["Listname"].ToString().Contains(value) select new ContactLists() { ID = dr["ID"].ToString(), Listname = dr["Listname"].ToString(), Datecreated = Convert.ToDateTime(dr["Datecreated"]).ToString("dd-MMM-yyyy hh:mm"), CreatedBy = dr["CreatedBy"].ToString() }).Skip(startRec).Take(pageSize).ToList(); totalCount = listsCount.Count(); filteredCount = contactLists.Count(); } var sortedColumns = requestModel.Columns.GetSortedColumns(); var orderByString = String.Empty; foreach (var column in sortedColumns) { orderByString += orderByString != String.Empty ? "," : ""; orderByString += (column.Data) + (column.SortDirection == Column.OrderDirection.Ascendant ? " asc" : " desc"); } var data = contactLists.Select(emList => new { ID = emList.ID, Listname = emList.Listname, Datecreated = emList.Datecreated, CreatedBy = emList.CreatedBy }).ToList(); return(Json(new DataTablesResponse(requestModel.Draw, data, totalCount, totalCount), JsonRequestBehavior.AllowGet)); } catch (Exception ex) { //LogError logerror = new LogError(); //logerror.ErrorLog("", LoginUser, "", "Requests/GetRequests", "Requests", "GetRequests", "FetchIncidents Error", ex.Message.ToString(), 0); return(Json(new { data = "Error has occured" }, JsonRequestBehavior.AllowGet)); } }