Пример #1
0
        public response Get()
        {
            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("GetCategory", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    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;



                    CategoryList list = new CategoryList();
                    foreach (DataRow row in dataTable.Rows)
                    {
                        category myprod = new category();
                        myprod.ID       = row["ID"].ToString();
                        myprod.Category = row["Category"].ToString();


                        list.categoryLists.Add(myprod);
                    }
                    response.AddCategoryList(list);

                    response.log.Add(numberOfRecords + " Records found");
                }
            }
            return(response);
        }
Пример #2
0
        public response UpdateTheme(int ID, int theme)
        {
            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("UpdateTheme", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@Theme", SqlDbType.Int).Value = theme;
                    cmd.Parameters.Add("@ID", SqlDbType.Int).Value    = ID;

                    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 = 1;
                    response.log.Add(numberOfRecords + " Records found");
                }
            }
            return(response);
        }
Пример #3
0
        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;
        }
Пример #4
0
        public response Get(string searchString, int theme, int category, int partofalbum, int index, int limit)
        {
            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("GetSearchAlbum", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@SearchString", SqlDbType.NVarChar).Value = searchString;

                    if (theme > 0)
                    {
                        cmd.Parameters.Add("@Theme", SqlDbType.Int).Value = theme;
                    }
                    else
                    {
                        cmd.Parameters.Add("@Theme", SqlDbType.Int).Value = DBNull.Value;
                    }


                    if (category > 0)
                    {
                        cmd.Parameters.Add("@Category", SqlDbType.Int).Value = category;
                    }
                    else
                    {
                        cmd.Parameters.Add("@Category", SqlDbType.Int).Value = DBNull.Value;
                    }

                    if (partofalbum > 0)
                    {
                        cmd.Parameters.Add("@PartOfAlbum", SqlDbType.Int).Value = partofalbum;
                    }
                    else
                    {
                        cmd.Parameters.Add("@PartOfAlbum", SqlDbType.Int).Value = DBNull.Value;
                    }



                    cmd.Parameters.Add("@PageIndex", SqlDbType.Int).Value = index;
                    cmd.Parameters.Add("@PageSize", SqlDbType.Int).Value  = limit;
                    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;

                    if (index > 0)
                    {
                        ProductCertificatesList list = new ProductCertificatesList();
                        foreach (DataRow row in dataTable.Rows)
                        {
                            productCertificate myprod = new productCertificate();
                            myprod.ID           = row["ID"].ToString();
                            myprod.ShortName    = row["ShortName"].ToString();
                            myprod.FullName     = row["FullName"].ToString();
                            myprod.HttpPathName = row["HttpPathName"].ToString();
                            myprod.PathName     = row["PathName"].ToString();
                            myprod.Category     = row["Category"].ToString();
                            myprod.Search       = row["Search"].ToString();
                            myprod.PartOfAlbum  = row["PartOfAlbum"].ToString();
                            myprod.Albumjpg     = row["Albumjpg"].ToString();
                            myprod.Albumpdf     = row["Albumpdf"].ToString();
                            myprod.Theme        = row["Theme"].ToString();
                            myprod.ThemeName    = row["ThemeName"].ToString();
                            response.result     = Convert.ToInt16(row["totalRecords"].ToString());


                            list.productCertificates.Add(myprod);
                        }
                        response.AddProductCertificatesList(list);
                    }

                    else
                    {
                        foreach (DataRow row in dataTable.Rows)
                        {
                            response.result = System.Convert.ToInt32(row["totalRecords"]);
                        }
                    }
                    response.log.Add(numberOfRecords + " Records found");
                }
            }
            return(response);
        }