Пример #1
0
        public response GetSpecificStory(int ID)
        {
            var dataTable = new System.Data.DataTable();

            dataTable = new System.Data.DataTable {
                TableName = "Stories"
            };
            string connString = URLInfo.GetDataBaseConnectionString();

            System.IO.StringWriter writer = new System.IO.StringWriter();
            string   returnString         = "";
            response response             = new response();

            response.result = 0;
            using (System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(connString))
            {
                using (System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("GetSpecificStory", con))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Parameters.Add("@ID", System.Data.SqlDbType.NVarChar).Value = ID;
                    con.Open();
                    var dataReader = cmd.ExecuteReader();
                    dataTable.Load(dataReader);
                    dataTable.WriteXml(writer, System.Data.XmlWriteMode.WriteSchema, false);
                    returnString = writer.ToString();
                    int numberOfRecords = dataTable.Rows.Count;
                    response.result = numberOfRecords;



                    SpecificStoryList list = new SpecificStoryList();
                    foreach (System.Data.DataRow row in dataTable.Rows)
                    {
                        specificStory myprod = new specificStory();
                        myprod.ID                 = row["ID"].ToString();
                        myprod.JakataID           = row["JakataID"].ToString();
                        myprod.AnimalType         = row["AnimalType"].ToString();
                        myprod.Comments           = row["Comments"].ToString();
                        myprod.MoralType          = row["MoralType"].ToString();
                        myprod.Stories            = row["Stories"].ToString();
                        myprod.StoryCategorytName = row["StoryCategorytName"].ToString();
                        myprod.Title              = row["Title"].ToString();


                        list.specificStory.Add(myprod);
                    }
                    response.AddSpecificStoryList(list);

                    response.log.Add(numberOfRecords + " Records found");
                }
            }
            return(response);
        }
Пример #2
0
 //Simply
 public System.Collections.IList AddSpecificStoryList(SpecificStoryList list)
 {
     data.Add(list);
     return(data);
 }
Пример #3
0
        //public response GetSpecificStory(Story myStoryies)
        public String GetSpecificStory(Story myStoryies)
        {
            var dataTable = new System.Data.DataTable();

            dataTable = new System.Data.DataTable {
                TableName = "Stories"
            };
            string connString = URLInfo.GetDataBaseConnectionString();

            System.IO.StringWriter writer = new System.IO.StringWriter();
            string   returnString         = "";
            response response             = new response();

            response.result = 0;
            string resultstring = "";

            SpecificStoryList list = new SpecificStoryList();



            using (System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(connString))
            {
                using (System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("GetSearchStory", con))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;



                    //cmd.Add("@JakataID", myStory.JakataID);
                    //cmd.Add("@StoryCategorytName", 1);
                    //cmd.Add("@Title", myStory.Title);
                    //cmd.Add("@AnimalType", myStory.AnimalType);


                    if (myStoryies.Title > 0)
                    {
                        cmd.Parameters.Add("@Title", System.Data.SqlDbType.NVarChar).Value = myStoryies.Title;
                    }

                    if (myStoryies.JakataID > 0)
                    {
                        cmd.Parameters.Add("@JakataID", System.Data.SqlDbType.Int).Value = myStoryies.JakataID;
                    }

                    if (myStoryies.AnimalType != "0")
                    {
                        cmd.Parameters.Add("@AnimalType", System.Data.SqlDbType.NVarChar).Value = myStoryies.AnimalType;
                    }

                    if (myStoryies.MoralType > 0)
                    {
                        cmd.Parameters.Add("@MoralType", System.Data.SqlDbType.Int).Value = myStoryies.MoralType;
                    }

                    if (myStoryies.Comments != "0")
                    {
                        cmd.Parameters.Add("@Comments", System.Data.SqlDbType.NVarChar).Value = myStoryies.Comments;
                    }

                    if (myStoryies.Stories != "0")
                    {
                        cmd.Parameters.Add("@Stories", System.Data.SqlDbType.NVarChar).Value = myStoryies.Stories;
                    }


                    con.Open();
                    var dataReader = cmd.ExecuteReader();
                    dataTable.Load(dataReader);
                    dataTable.WriteXml(writer, System.Data.XmlWriteMode.WriteSchema, false);
                    returnString = writer.ToString();

                    //return returnString;
                    int numberOfRecords = dataTable.Rows.Count;
                    response.result = numberOfRecords;



                    //SpecificStoryList list = new SpecificStoryList();
                    foreach (System.Data.DataRow row in dataTable.Rows)
                    {
                        //specificStory myprod = new specificStory();
                        resultstring = resultstring + row["ID"].ToString() + "|";


                        //list.specificStory.Add(myprod);
                    }
                    //response.AddSpecificStoryList(list);

                    //response.log.Add(numberOfRecords + " Records found");
                }
            }

            //return list;
            return(resultstring);
            //return response;
        }