public response GetAll(int category, int theme) { try { //LogEntry("Theme"+theme); //LogEntry("category" + category); var dataTable = new DataTable(); dataTable = new DataTable { TableName = "Album" }; //var conString1 = ConfigurationManager.ConnectionStrings["LocalEvolution"]; //string connString = conString1.ConnectionString; string connString = URLInfo.GetDataBaseConnectionString(); System.IO.StringWriter writer = new System.IO.StringWriter(); string returnString = ""; response response = new response(); response.result = 0; using (SqlConnection con = new SqlConnection(connString)) { using (SqlCommand cmd = new SqlCommand("GetPartOfAlbumAll", con)) { cmd.CommandType = CommandType.StoredProcedure; if (category != 0) { cmd.Parameters.Add("@Category", SqlDbType.NVarChar).Value = category; } if (theme != 0) { cmd.Parameters.Add("@Theme", SqlDbType.NVarChar).Value = theme; } con.Open(); var dataReader = cmd.ExecuteReader(); dataTable.Load(dataReader); dataTable.WriteXml(writer, XmlWriteMode.WriteSchema, false); returnString = writer.ToString(); int numberOfRecords = dataTable.Rows.Count; response.result = numberOfRecords; CategoryListall list = new CategoryListall(); foreach (DataRow row in dataTable.Rows) { categoryall catType = new categoryall(); catType.RECEIPTNO = row["RECEIPTNO"].ToString(); catType.Title = row["Title"].ToString(); catType.Picture = row["Picture"].ToString(); catType.url = row["url"].ToString(); list.categoryListsall.Add(catType); } response.AddCategoryListAll(list); response.log.Add(numberOfRecords + " Records found"); } return(response); } } catch (System.Exception ex) { LogEntry(ex.ToString());//replace with something like Serilog throw; } //return response; }
public IList AddCategoryListAll(CategoryListall list) { data.Add(list); return(data); }