public void GetCorrectResultGettingById()
        {
            var paper = new PaperIssue()
            {
                CityOfPublishing = "Саратов",
                DateOfIssue      = new DateTime(2010, 01, 01),
                Paper            = new Paper
                {
                    Issn = "ISSN 1111-1111",
                    Name = "Аргументы и факты",
                },
                Id            = 1,
                IssueNumber   = 1,
                Note          = "Some note",
                NumberOfPages = 200,
                Publisher     = new Publisher()
                {
                    Id            = 1,
                    PublisherName = "Правда",
                },
                YearOfPublishing = 2011,
            };

            this.dao.Setup(x => x.GetItemById(It.IsAny <int>())).Returns(paper);
            Assert.IsTrue(paper.Equals(this.logic.GetById(88)));
        }
Esempio n. 2
0
        public bool Update(PaperIssue paper)
        {
            using (var connection = Common.CreateConnection())
            {
                connection.Open();
                var cmd = connection.CreateCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "UpdatePaperIssue";

                IDbDataParameter id                = Common.CreateParameter("@id", DbType.Int32, paper.Id);
                IDbDataParameter paperId           = Common.CreateParameter("@paperId", DbType.Int32, paper.Paper.Id);
                IDbDataParameter cityOfPublication = Common.CreateParameter("@cityOfPublication", DbType.String, paper.CityOfPublishing);
                IDbDataParameter publisherId       = Common.CreateParameter("@publisherId", DbType.Int32, paper.Publisher.Id);
                IDbDataParameter numberOfPages     = Common.CreateParameter("@numberOfPages", DbType.Int32, paper.NumberOfPages);
                IDbDataParameter note              = Common.CreateParameter("@note", DbType.String, paper.Note);
                IDbDataParameter numberOfIssue     = Common.CreateParameter("@number_of_issue", DbType.Int32, paper.IssueNumber);
                IDbDataParameter yearOfPublishing  = Common.CreateParameter("@yearOfPublishing", DbType.Int32, paper.YearOfPublishing);
                IDbDataParameter dateOfIssue       = Common.CreateParameter("@dateOfIssue", DbType.Date, paper.DateOfIssue);

                cmd.Parameters.AddRange(new[] { id, paperId, cityOfPublication, publisherId, numberOfPages, note, numberOfIssue, yearOfPublishing, dateOfIssue });

                int result = cmd.ExecuteNonQuery();

                return(result > 0);
            }
        }
        public void PaperIssueExistsInDatabaseAfterAdding()
        {
            PaperIssue pi = new PaperIssue()
            {
                CityOfPublishing = "Mexico",
                DateOfIssue      = new DateTime(1940, 02, 02),
                Id          = 10,
                IssueNumber = 788,
                Note        = "The most read mexican newspaper!",
                Paper       = new Paper()
                {
                    Id   = 3,
                    Issn = "ISSN 1111-1111",
                    Name = "Wall-Street Journal"
                },
                Publisher = new Publisher()
                {
                    Id            = 5,
                    PublisherName = "Fairwood Press"
                },
                NumberOfPages    = 50,
                YearOfPublishing = 1940
            };

            this.dao.AddItem(pi);
            Assert.IsTrue(this.dao.Exists(pi));
        }
        public void GetCorrectResultWhenPaperIssueAlreadyExists()
        {
            PaperIssue pi = new PaperIssue()
            {
                CityOfPublishing = "New-York",
                DateOfIssue      = new DateTime(1910, 01, 01),
                Id            = 6,
                IssueNumber   = 2,
                Note          = "xxx",
                NumberOfPages = 22,
                Paper         = new Paper()
                {
                    Id   = 3,
                    Issn = "ISSN 1111-1111",
                    Name = "Wall-Street Journal"
                },
                Publisher = new Publisher()
                {
                    Id            = 5,
                    PublisherName = "Fairwood Press"
                },
                YearOfPublishing = 1910,
            };
            int i = this.dao.AddItem(pi);

            Assert.IsTrue(-1 == i);
        }
        public void PaperIssueExistsWorksProperly()
        {
            PaperIssue pi = new PaperIssue()
            {
                CityOfPublishing = "New-York",
                DateOfIssue      = new DateTime(1910, 01, 01),
                Id            = 6,
                IssueNumber   = 2,
                Note          = "xxx",
                NumberOfPages = 22,
                Paper         = new Paper()
                {
                    Id   = 3,
                    Issn = "ISSN 1111-1111",
                    Name = "Wall-Street Journal"
                },
                Publisher = new Publisher()
                {
                    Id            = 5,
                    PublisherName = "Fairwood Press"
                },
                YearOfPublishing = 1910,
            };

            Assert.IsTrue(this.dao.Exists(pi));
        }
        public void GetByIdExtractAddedEntityCorrectly()
        {
            PaperIssue pi = new PaperIssue()
            {
                CityOfPublishing = "Mexico",
                DateOfIssue      = new DateTime(1940, 02, 02),
                Id          = 10,
                IssueNumber = 788,
                Note        = "The most read mexican newspaper!",
                Paper       = new Paper()
                {
                    Id   = 3,
                    Issn = "ISSN 1111-1111",
                    Name = "Wall-Street Journal"
                },
                Publisher = new Publisher()
                {
                    Id            = 5,
                    PublisherName = "Fairwood Press"
                },
                NumberOfPages    = 50,
                YearOfPublishing = 1940
            };
            int result = this.dao.AddItem(pi);
            var item   = this.dao.GetItemById(result);

            Assert.IsTrue(item.Equals(pi));
        }
        public void AddNewPaperIssueWorksCorrectly()
        {
            PaperIssue pi = new PaperIssue()
            {
                CityOfPublishing = "Mexico",
                DateOfIssue      = new DateTime(1940, 02, 02),
                Id          = 10,
                IssueNumber = 788,
                Note        = "The most read mexican newspaper!",
                Paper       = new Paper()
                {
                    Id   = 3,
                    Issn = "ISSN 1111-1111",
                    Name = "Wall-Street Journal"
                },
                Publisher = new Publisher()
                {
                    Id            = 5,
                    PublisherName = "Fairwood Press"
                },
                NumberOfPages    = 50,
                YearOfPublishing = 1940
            };
            int result = this.dao.AddItem(pi);

            Assert.IsTrue(result > 0);
        }
        public void GetByIdReturnsCorrectPaperIssue()
        {
            PaperIssue pi = new PaperIssue()
            {
                CityOfPublishing = "New-York",
                DateOfIssue      = new DateTime(1910, 01, 01),
                Id            = 6,
                IssueNumber   = 2,
                Note          = "xxx",
                NumberOfPages = 22,
                Paper         = new Paper()
                {
                    Id   = 3,
                    Issn = "ISSN 1111-1111",
                    Name = "Wall-Street Journal"
                },
                Publisher = new Publisher()
                {
                    Id            = 5,
                    PublisherName = "Fairwood Press"
                },
                YearOfPublishing = 1910,
            };

            var result = this.dao.GetItemById(6);

            Assert.IsTrue(result.Equals(pi));
        }
        public void GetCorrectResultWhenGetAllPapers()
        {
            var paper = new PaperIssue()
            {
                CityOfPublishing = "Саратов",
                DateOfIssue      = new DateTime(2010, 01, 01),
                Paper            = new Paper
                {
                    Issn = "ISSN 1111-1111",
                    Name = "Аргументы и факты",
                },
                Id            = 1,
                IssueNumber   = 1,
                Note          = "Some note",
                NumberOfPages = 200,
                Publisher     = new Publisher()
                {
                    Id            = 1,
                    PublisherName = "Правда",
                },
                YearOfPublishing = 2011,
            };

            this.dao.Setup(x => x.GetAllItems()).Returns(new List <PaperIssue>()
            {
                new PaperIssue
                {
                    CityOfPublishing = "Саратов",
                    DateOfIssue      = new DateTime(2010, 01, 01),
                    Paper            = new Paper
                    {
                        Issn = "ISSN 1111-1111",
                        Name = "Аргументы и факты",
                    },
                    Id            = 1,
                    IssueNumber   = 1,
                    Note          = "Some note",
                    NumberOfPages = 200,
                    Publisher     = new Publisher()
                    {
                        Id            = 1,
                        PublisherName = "Правда",
                    },
                    YearOfPublishing = 2011,
                }
            });

            var result = this.logic.GetAll();

            Assert.IsTrue(result.Contains(paper));
        }
Esempio n. 10
0
        public IEnumerable <PaperIssue> GetPaperIssuesByPaperId(int id)
        {
            List <PaperIssue> list = new List <PaperIssue>();

            using (var connection = Common.CreateConnection())
            {
                connection.Open();
                var cmd = connection.CreateCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "GetPaperIssuesByPaperId";

                IDbDataParameter paperIdDb = Common.CreateParameter <int>("@id", DbType.Int32, id);
                cmd.Parameters.Add(paperIdDb);

                PaperIssue pi     = new PaperIssue();
                var        reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    pi = new PaperIssue()
                    {
                        CityOfPublishing = (string)reader["cityOfPublication"],
                        DateOfIssue      = (DateTime)reader["dateOfIssue"],
                        Id            = (int)reader["library_item_ID"],
                        IssueNumber   = (int)reader["number_of_issue"],
                        Note          = (string)reader["note"],
                        NumberOfPages = (int)reader["number_of_pages"],
                        Paper         = new Paper()
                        {
                            Id   = (int)reader["id"],
                            Issn = reader["ISSN"] as string,
                            Name = (string)reader["title"]
                        },
                        Publisher = new Publisher
                        {
                            Id            = (int)reader["publisher_Id"],
                            PublisherName = (string)reader["publisherName"],
                        },
                        YearOfPublishing = (int)reader["YearOfPublication"],
                    };
                    list.Add(pi);
                }
            }

            return(list.ToArray());
        }
Esempio n. 11
0
        public bool Exists(PaperIssue paper)
        {
            if (!string.IsNullOrEmpty(paper.Paper.Issn))
            {
                var result = from paperEnt in PaperIssueRepository.GetPaperIssueRepository().Papers
                             where paperEnt.Paper.Issn == paper.Paper.Issn
                             select paperEnt;

                return(result.Any());
            }
            else
            {
                var result = from paperEnt in PaperIssueRepository.GetPaperIssueRepository().Papers
                             where paperEnt.Paper.Name == paper.Paper.Name
                             where paperEnt.Publisher == paper.Publisher
                             where paperEnt.YearOfPublishing == paper.YearOfPublishing
                             select paperEnt;
                return(result.Any());
            }
        }
Esempio n. 12
0
        public bool Exists(PaperIssue paper)
        {
            using (var connection = Common.CreateConnection())
            {
                connection.Open();
                var cmd = connection.CreateCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "PaperIssueExists";

                IDbDataParameter id          = Common.CreateOutputParameter("@Exists", DbType.Int32);
                IDbDataParameter publisherId = Common.CreateParameter("@publisherID", DbType.Int32, paper.Publisher.Id);
                IDbDataParameter dataOfIssue = Common.CreateParameter("@dateOfIssue", DbType.Date, paper.DateOfIssue);
                IDbDataParameter title       = Common.CreateParameter("@title", DbType.String, paper.Paper.Name);

                cmd.Parameters.AddRange(new[] { id, publisherId, dataOfIssue, title });

                cmd.ExecuteNonQuery();

                return((int)id.Value == 1);
            }
        }
Esempio n. 13
0
 public bool Update(PaperIssue paper)
 {
     throw new NotImplementedException();
 }
Esempio n. 14
0
 public int AddItem(PaperIssue paper)
 {
     paper.Id = ++IdStorage.UniqueId;
     PaperIssueRepository.GetPaperIssueRepository().Papers.Add(paper);
     return(IdStorage.UniqueId);
 }
Esempio n. 15
0
        public IEnumerable <LibraryItem> GetAllLibraryItems(int pageNumber, int numberOfResults, out int totalResult)
        {
            List <LibraryItem> list = new List <LibraryItem>();
            //totalResult = -1;
            int offset = (pageNumber - 1) * numberOfResults;

            using (var connection = Common.CreateConnection())
            {
                connection.Open();
                var cmd = connection.CreateCommand();

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "GetAllOffset";


                IDbDataParameter sortingMode       = Common.CreateParameter <int>("@sortParam", DbType.Int32, 0);
                IDbDataParameter offsetDB          = Common.CreateParameter <int>("@offset", DbType.Int32, offset);
                IDbDataParameter numberOfResultsDB = Common.CreateParameter <int>("@page", DbType.Int32, numberOfResults);
                IDbDataParameter totalResultDB     = Common.CreateOutputParameter("@totalResult", DbType.Int32);

                cmd.Parameters.AddRange(new[] { sortingMode, offsetDB, numberOfResultsDB, totalResultDB });

                var    reader = cmd.ExecuteReader();
                string type;
                while (reader.Read())
                {
                    type = (string)reader["Type"];
                    if (type == "patent")
                    {
                        Patent patent = new Patent()
                        {
                            Country           = (string)reader["country"],
                            DateOfPublication = (DateTime)reader["date_of_publication"],
                            Id                  = (int)reader["library_item_ID"],
                            Name                = (string)reader["title"],
                            Note                = (string)reader["note"],
                            NumberOfPages       = (int)reader["number_of_pages"],
                            RegNumber           = (string)reader["reg_number"],
                            SubmissionDocuments = (DateTime)reader["date_of_submission"],
                            YearOfPublishing    = (int)reader["YearOfPublication"],
                        };

                        XElement xmlAuthor = XElement.Parse((string)reader["authors"]);
                        patent.Authors = new HashSet <Author>(Common.GetAuthorsFromXML(xmlAuthor));

                        list.Add(patent);
                    }
                    else if (type == "paper")
                    {
                        PaperIssue pi = new PaperIssue()
                        {
                            CityOfPublishing = (string)reader["cityOfPublication"],
                            DateOfIssue      = (DateTime)reader["dateOfIssue"],
                            Id            = (int)reader["library_item_ID"],
                            IssueNumber   = (int)reader["number_of_issue"],
                            Note          = (string)reader["note"],
                            NumberOfPages = (int)reader["number_of_pages"],
                            Paper         = new Paper()
                            {
                                Issn = reader["ISSN"] as string,
                                Name = (string)reader["title"]
                            },
                            Publisher = new Publisher
                            {
                                Id            = (int)reader["publisher_Id"],
                                PublisherName = (string)reader["publisherName"],
                            },
                            YearOfPublishing = (int)reader["YearOfPublication"],
                        };

                        list.Add(pi);
                    }
                    else if (type == "book")
                    {
                        Book book = new Book()
                        {
                            CityOfPublishing = (string)reader["city_of_publishing"],
                            Id            = (int)reader["library_item_ID"],
                            ISBN          = reader["ISBN"] as string,
                            Name          = (string)reader["title"],
                            NumberOfPages = (int)reader["number_of_pages"],
                            Note          = (string)reader["note"],
                            Publisher     = new Publisher()
                            {
                                Id            = (int)reader["publisher_Id"],
                                PublisherName = (string)reader["publisherName"]
                            },
                            YearOfPublishing = (int)reader["YearOfPublication"]
                        };

                        XElement xmlAuthor = XElement.Parse((string)reader["authors"]);
                        book.Authors = new HashSet <Author>(Common.GetAuthorsFromXML(xmlAuthor));

                        list.Add(book);
                    }
                    else
                    {
                        throw new Exception("Unexpected type of an object in database");
                    }
                }

                reader.Close();
                totalResult = (int)totalResultDB.Value;
            }
            return(list.ToArray());
        }
Esempio n. 16
0
        public LibraryItem GetItemById(int id)
        {
            LibraryItem li = null;

            using (IDbConnection connection = Common.CreateConnection())
            {
                connection.Open();
                IDbCommand cmd = connection.CreateCommand();

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "GetItemById";

                IDbDataParameter itemDbId = Common.CreateParameter("@id", DbType.Int32, id);

                cmd.Parameters.Add(itemDbId);


                var reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    string type = (string)reader["Type"];
                    if (type == "patent")
                    {
                        Patent patent = new Patent()
                        {
                            Country           = (string)reader["country"],
                            DateOfPublication = (DateTime)reader["date_of_publication"],
                            Id                  = (int)reader["library_item_ID"],
                            Name                = (string)reader["title"],
                            Note                = (string)reader["note"],
                            NumberOfPages       = (int)reader["number_of_pages"],
                            RegNumber           = (string)reader["reg_number"],
                            SubmissionDocuments = (DateTime)reader["date_of_submission"],
                            YearOfPublishing    = (int)reader["YearOfPublication"],
                        };

                        XElement xmlAuthor = XElement.Parse((string)reader["authors"]);
                        patent.Authors = new HashSet <Author>(Common.GetAuthorsFromXML(xmlAuthor));

                        li = patent;
                    }
                    else if (type == "paper")
                    {
                        PaperIssue pi = new PaperIssue()
                        {
                            CityOfPublishing = (string)reader["cityOfPublication"],
                            DateOfIssue      = (DateTime)reader["dateOfIssue"],
                            Id            = (int)reader["library_item_ID"],
                            IssueNumber   = (int)reader["number_of_issue"],
                            Note          = (string)reader["note"],
                            NumberOfPages = (int)reader["number_of_pages"],
                            Paper         = new Paper()
                            {
                                Id   = (int)reader["id"],
                                Issn = reader["ISSN"] as string,
                                Name = (string)reader["title"]
                            },
                            Publisher = new Publisher
                            {
                                Id            = (int)reader["publisher_Id"],
                                PublisherName = (string)reader["publisherName"],
                            },
                            YearOfPublishing = (int)reader["YearOfPublication"],
                        };

                        li = pi;
                    }
                    else if (type == "book")
                    {
                        Book book = new Book()
                        {
                            CityOfPublishing = (string)reader["city_of_publishing"],
                            Id            = (int)reader["library_item_ID"],
                            ISBN          = reader["ISBN"] as string,
                            Name          = (string)reader["title"],
                            NumberOfPages = (int)reader["number_of_pages"],
                            Note          = (string)reader["note"],
                            Publisher     = new Publisher()
                            {
                                Id            = (int)reader["publisher_Id"],
                                PublisherName = (string)reader["publisherName"]
                            },
                            YearOfPublishing = (int)reader["YearOfPublication"]
                        };

                        XElement xmlAuthor = XElement.Parse((string)reader["authors"]);
                        book.Authors = new HashSet <Author>(Common.GetAuthorsFromXML(xmlAuthor));

                        li = book;
                    }
                    else
                    {
                        throw new Exception("Unexpected type of an object in database");
                    }
                }
            }

            return(li);
        }
Esempio n. 17
0
        public int Add(Paper paper, string cityOfPublishing, Publisher publisher, int yearOfPublishing, int numberOfPages, string note, int issueNumber, DateTime dateOfIssue)
        {
            if (paper == null)
            {
                throw new ArgumentException();
            }

            if (this.paperValidator.IsValidCityOfPublishing(cityOfPublishing))
            {
                throw new ArgumentException();
            }

            if (this.paperValidator.IsValidPublisher(publisher))
            {
                throw new ArgumentException();
            }

            if (this.paperValidator.AreValidDates(dateOfIssue, yearOfPublishing))
            {
                throw new ArgumentException();
            }

            if (this.paperValidator.IsValidNumberPages(numberOfPages))
            {
                throw new ArgumentException();
            }

            if (this.paperValidator.IsValidNote(note))
            {
                throw new ArgumentException();
            }

            if (this.paperValidator.IsValidIssueNumber(issueNumber))
            {
                throw new ArgumentException();
            }

            if (this.paperValidator.IsValidPaper(paper))
            {
                throw new ArgumentException();
            }

            PaperIssue newPaperIssue = new PaperIssue
            {
                CityOfPublishing = cityOfPublishing,
                Publisher        = publisher,
                YearOfPublishing = yearOfPublishing,
                NumberOfPages    = numberOfPages,
                Note             = note,
                IssueNumber      = issueNumber,
                DateOfIssue      = dateOfIssue,
                Paper            = paper,
            };

            if (this.paperDAO.Exists(newPaperIssue))
            {
                throw new ArgumentException();
            }

            return(this.paperDAO.AddItem(newPaperIssue));
        }
Esempio n. 18
0
        public bool Update(int id, Paper paper, string cityOfPublishing, Publisher publisher, int yearOfPublishing, int numberOfPages, string note, int issueNumber, DateTime dateOfIssue)
        {
            if (id < 1)
            {
                throw new ArgumentException();
            }

            if (paper == null)
            {
                throw new ArgumentException();
            }

            if (this.paperValidator.IsValidCityOfPublishing(cityOfPublishing))
            {
                throw new ArgumentException();
            }

            if (this.paperValidator.IsValidPublisher(publisher))
            {
                throw new ArgumentException();
            }

            if (this.paperValidator.AreValidDates(dateOfIssue, yearOfPublishing))
            {
                throw new ArgumentException();
            }

            if (this.paperValidator.IsValidNumberPages(numberOfPages))
            {
                throw new ArgumentException();
            }

            if (this.paperValidator.IsValidNote(note))
            {
                throw new ArgumentException();
            }

            if (this.paperValidator.IsValidIssueNumber(issueNumber))
            {
                throw new ArgumentException();
            }

            if (this.paperValidator.IsValidPaper(paper))
            {
                throw new ArgumentException();
            }

            PaperIssue newPaperIssue = new PaperIssue
            {
                CityOfPublishing = cityOfPublishing,
                Publisher        = publisher,
                YearOfPublishing = yearOfPublishing,
                NumberOfPages    = numberOfPages,
                Note             = note,
                IssueNumber      = issueNumber,
                DateOfIssue      = dateOfIssue,
                Paper            = paper,
            };

            if (this.paperDAO.Exists(newPaperIssue))
            {
                throw new ArgumentException();
            }

            try
            {
                return(this.paperDAO.Update(newPaperIssue));
            }
            catch (Exception e)
            {
                logger.Error("DAL", e);
                throw new DalException(e);
            }
        }
Esempio n. 19
0
        public IEnumerable <LibraryItem> GetAllItemsSortedByYearOfPublishing(Enums.Order order)
        {
            List <LibraryItem> list = new List <LibraryItem>();

            using (IDbConnection connection = Common.CreateConnection())
            {
                connection.Open();
                IDbCommand cmd = connection.CreateCommand();

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "GetAll";

                IDbDataParameter sortingMode = Common.CreateParameter("@sortParam", DbType.Int32, (int)order);

                cmd.Parameters.Add(sortingMode);

                var    reader = cmd.ExecuteReader();
                string type;
                while (reader.Read())
                {
                    type = (string)reader["Type"];
                    if (type == "patent")
                    {
                        Patent patent = new Patent()
                        {
                            Country           = (string)reader["country"],
                            DateOfPublication = (DateTime)reader["date_of_publication"],
                            Id                  = (int)reader["library_item_ID"],
                            Name                = (string)reader["title"],
                            Note                = (string)reader["note"],
                            NumberOfPages       = (int)reader["number_of_pages"],
                            RegNumber           = (string)reader["reg_number"],
                            SubmissionDocuments = (DateTime)reader["date_of_submission"],
                            YearOfPublishing    = (int)reader["YearOfPublication"],
                        };

                        XElement xmlAuthor = XElement.Parse((string)reader["authors"]);
                        patent.Authors = new HashSet <Author>(Common.GetAuthorsFromXML(xmlAuthor));

                        list.Add(patent);
                    }
                    else if (type == "paper")
                    {
                        PaperIssue pi = new PaperIssue()
                        {
                            CityOfPublishing = (string)reader["cityOfPublication"],
                            DateOfIssue      = (DateTime)reader["dateOfIssue"],
                            Id            = (int)reader["library_item_ID"],
                            IssueNumber   = (int)reader["number_of_issue"],
                            Note          = (string)reader["note"],
                            NumberOfPages = (int)reader["number_of_pages"],
                            Paper         = new Paper()
                            {
                                Id   = (int)reader["id"],
                                Issn = (string)reader["ISSN"],
                                Name = (string)reader["title"]
                            },
                            Publisher = new Publisher
                            {
                                Id            = (int)reader["publisherId"],
                                PublisherName = (string)reader["publisherName"],
                            },
                            YearOfPublishing = (int)reader["YearOfPublication"],
                        };

                        list.Add(pi);
                    }
                    else if (type == "book")
                    {
                        Book book = new Book()
                        {
                            CityOfPublishing = (string)reader["city_of_publishing"],
                            Id            = (int)reader["library_item_ID"],
                            ISBN          = (string)reader["ISBN"],
                            Name          = (string)reader["title"],
                            NumberOfPages = (int)reader["number_of_pages"],
                            Note          = (string)reader["note"],
                            Publisher     = new Publisher()
                            {
                                Id            = (int)reader["publisher_Id"],
                                PublisherName = (string)reader["publisherName"]
                            },
                            YearOfPublishing = (int)reader["YearOfPublication"]
                        };

                        XElement xmlAuthor = XElement.Parse((string)reader["authors"]);
                        book.Authors = new HashSet <Author>(Common.GetAuthorsFromXML(xmlAuthor));
                    }
                    else
                    {
                        throw new Exception("Unexpected type of an object in database");
                    }
                }
            }

            return(list.ToArray());
        }