Beispiel #1
0
        public override BookContainer <SpecialLiterature> GetAll(string type = null, BookContainer <SpecialLiterature> section = null, int?sectionId = null)
        {
            SpecialLiteratureSection books = new SpecialLiteratureSection();

            base.GetAll("SpecialLiterature", books, 2);

            return(GetSpecialLiterature(books, type, section, sectionId));
        }
Beispiel #2
0
        public override BookContainer <SpecialLiterature> Search(string text, BookFilter filter, string type = null, BookContainer <SpecialLiterature> section = null, int?sectionId = null)
        {
            SpecialLiteratureSection books = new SpecialLiteratureSection();

            base.Search(text, filter, "SpecialLiterature", books, 2);

            return(GetSpecialLiterature(books, type, section, sectionId));
        }
Beispiel #3
0
        private BookContainer <SpecialLiterature> GetSpecialLiterature(SpecialLiteratureSection books, string type, BookContainer <SpecialLiterature> section, int?sectionId, string query = GetAllSpecialLiteratureQuery)
        {
            using (SqlConnection connection = new SqlConnection(_connectionString))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand(query, connection))
                {
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var bookId = (int)reader["id"];

                            if (books.Books.FirstOrDefault(b => b.Id == bookId) != null)
                            {
                                books.Books.First(b => b.Id == bookId).Field = (string)reader["field"];
                            }
                        }
                        return(books);
                    }
                }
            }
        }