public IEnumerable <LibraryItem> GetSortedByYearOfPublishing(Enums.Order order) { try { return(this.filteredDAO.GetAllItemsSortedByYearOfPublishing(order)); } catch (Exception e) { logger.Error("DAL", e); throw new DalException(e); } }
public IEnumerable <LibraryItem> GetAllItemsSortedByYearOfPublishing(Enums.Order order) { throw new NotImplementedException(); }
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()); }