public List <NameValueData> GetList() { string connstring = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString; var listOfPerson = new List <NameValueData>(); using (var connection = new SqlConnection(connstring)) { connection.Open(); string sql = "SELECT CityID AS Value,CityName AS Name FROM dbo.city"; using (var command = new SqlCommand(sql, connection)) { using (var reader = command.ExecuteReader()) { while (reader.Read()) { var person = new NameValueData(); person.Value = Convert.ToInt16(reader["Value"].ToString()); person.Name = reader["Name"].ToString(); listOfPerson.Add(person); } } } } return(listOfPerson); }
/// <summary> /// Get Make List /// </summary> /// <returns></returns> public List <NameValueData> GetMakeList() { List <NameValueData> makeDataList = new List <NameValueData>(); using (OracleConnection con = new OracleConnection(OracleConnectionHelper.ConnectionStringMaster)) { using (OracleCommand cmd = con.CreateCommand()) { if (con.State != ConnectionState.Open) { con.Open(); } cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "TW_GET_MAKE_LIST"; cmd.BindByName = true; cmd.Parameters.Add(OracleConnectionHelper.CreateParam(null, "REF_CURSOR", OracleDbType.RefCursor, ParameterDirection.Output)); using (IDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { NameValueData makedetail = new NameValueData(); makedetail.Name = reader.GetString(reader.GetOrdinal("NAME")); makedetail.Value = reader.GetInt32(reader.GetOrdinal("VALUE")); makedetail.OriginalName = reader.GetString(reader.GetOrdinal("MakeName")); makeDataList.Add(makedetail); } } } } return(makeDataList); }
/// <summary> /// Gets the status list. /// </summary> /// <returns></returns> public List <NameValueData> GetStatusList() { List <NameValueData> statuses = new List <NameValueData>(); Dictionary <string, string> statusArray = new Dictionary <string, string>(); statusArray.Add("Completed", "Completed"); statusArray.Add("Sent Back", "Rework"); statusArray.Add("Submitted", "Pending"); foreach (var item in statusArray) { NameValueData status = new NameValueData(); status.Name = Convert.ToString(item.Key); status.Value = Convert.ToString(item.Value); statuses.Add(status); } //List statusList = this.web.Lists.GetByTitle(ICCPListNames.ICCPMAINLIST); //if (statusList != null) //{ // CamlQuery query = new CamlQuery(); // query.ViewXml = @"<View> // <Query> // <OrderBy> // <FieldRef Name='ID' Ascending='True' /> // </OrderBy> // <FieldRef Name='WorkflowStatus' /> // </Query> // </View>"; // ListItemCollection items = statusList.GetItems(query); // this.context.Load(items); // this.context.ExecuteQuery(); // if (items != null && items.Count > 0) // { // var distinctItems = items.ToList().Select(i => i.FieldValues["WorkflowStatus"]).Distinct().ToList(); // foreach (ListItem item in distinctItems) // { // NameValueData status = new NameValueData(); // status.Name = Convert.ToString(item["WorkflowStatus"]); // status.Value = Convert.ToString(item["WorkflowStatus"]); // statuses.Add(status); // } // } //} return(statuses); }
/// <summary> /// Gets the role list. /// </summary> /// <returns></returns> public List <NameValueData> GetRoleList() { List <NameValueData> roleList = new List <NameValueData>(); try { List spList = this.web.Lists.GetByTitle(Masters.ROLEMASTER); CamlQuery camlQuery = new CamlQuery(); camlQuery.ViewXml = @"<View> <Query> <OrderBy> <FieldRef Name='Role' Ascending='True' /> </OrderBy> </Query> </View>"; ListItemCollection items = spList.GetItems(camlQuery); this.context.Load(items); this.context.ExecuteQuery(); if (items != null && items.Count > 0) { foreach (ListItem item in items) { NameValueData role = new NameValueData(); role.Name = Convert.ToString(item["ID"]); role.Value = Convert.ToString(item["Role"]); roleList.Add(role); } } roleList.RemoveAll(m => m.Value == "Admin"); return(roleList); } catch (Exception ex) { Logger.Error("Error while get role list: Message = " + ex.Message + " ,Stack Trace = " + ex.StackTrace); return(roleList); } }