Пример #1
0
        public AuthorsList GetList()
        {
            AuthorsList   authors = new AuthorsList();
            SqlDataReader reader  = null;

            try
            {
                SqlCommand command = _connection.CreateCommand();
                command.CommandText = "SELECT * FROM Authors";

                reader = command.ExecuteReader();
                while (reader.Read())
                {
                    authors.Add(new Author((String)reader["FirstName"], (String)reader["LastName"]));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ooops", MessageBoxButton.OK);
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                {
                    reader.Close();
                }
            }
            return(authors);
        }
        private void button2_Click(object sender, EventArgs e)
        {
            BookServiceUtilJSON bookservice = new BookServiceUtilJSON("bookserviceaseece.azurewebsites.net", "", "api");
            //Test Author metoder
            AuthorsList alist = bookservice.GetAuthors();

            this.textBox1.Text = alist.Authors[alist.Authors.Count - 1].Name;
        }
Пример #3
0
        /*
         * Author metoder
         */
        public AuthorsList GetAuthors()
        {
            AuthorsList al = new AuthorsList(); //AuthorsList er en Wrapper model klasse der indpakker en List<Author> liste
            APIGetJSON <List <Author> > authlist = new APIGetJSON <List <Author> >(fullservicepath + "Authors");

            al.Authors = authlist.data;
            return(al);
        }
Пример #4
0
        private void DefaultParametrs(ContractEF contract = null, bool refresh = false)
        {
            if (!refresh)
            {
                archiveManager    = new ArchiveManager(dataManager);
                BanksList         = DataBaseClient.ReadBanks();
                ContractTypesList = DataBaseClient.ReadContractTypes();
                CurrenciesList    = DataBaseClient.ReadCurrencies();
                BrokersList       = DataBaseClient.ReadBrokers();
                AuthorsList       = DataBaseClient.ReadTraders();

                RangeList = new List <string>();
                RangeList.Add("От 1 ");
                RangeList.Add("От 20.000 тсч.");
                RangeList.Add("От 1.000.000 млн.");
                RangeList.Add("От 5.000.000 млн.");
                RangeList.Add("От 10.000.000 млн.");
                RangeList.Add("От 15.000.000 млн.");
                RangeList.Add("От 25.000.000 млн.");
                RangeList.Add("От 40.000.000 млн.");
                RangeList.Add("От 50.000.000 млн.");
                RangeList.Add("От 75.000.000 млн.");
                RangeList.Add("От 100.000.000 млн.");
                RangeList.Add("От 1.000.000.000 млрд.");
                SelectedRange = RangeList[0];

                ScanTypesList = new List <string>();
                ScanTypesList.Add("Копия");
                ScanTypesList.Add("Оригинал");
            }

            if (contract == null)
            {
                Contract               = new ContractEF();
                Contract.companyid     = companyId;
                Contract.agreementdate = DateTime.Now;
                SelectedContractType   = ContractTypesList[0];
                SelectedCurrency       = CurrenciesList[0];
                SelectedScanType       = ScanTypesList[0];
            }
            else
            {
                try {
                    if (contract.bankid != null)
                    {
                        SelectedBank = BanksList.Where(x => x.id == contract.bankid).FirstOrDefault();
                        SearchTxt    = SelectedBank.name;
                    }

                    SelectedContractType = ContractTypesList.Where(x => x.id == (contract.contracttypeid == null ? 1 : contract.contracttypeid)).FirstOrDefault();
                    SelectedCurrency     = CurrenciesList.Where(x => x.id == contract.currencyid).FirstOrDefault();
                    SelectedBroker       = BrokersList.Where(x => x.id == contract.brokerid).FirstOrDefault();
                    RatesList            = new ObservableCollection <RatesListEF>(DataBaseClient.ReadRatesList(Contract.id));
                    SelectedAuthor       = AuthorsList.FirstOrDefault(a => a.id == (contract.authorid == null ? 1 : contract.authorid));
                    SelectedScanType     = ScanTypesList[(contract.scantype == null ? 0 : (int)contract.scantype)];
                } catch (Exception) { }
            }
        }
Пример #5
0
        public IActionResult CreateBook(IEnumerable <int> AuthorIds, IEnumerable <int> CategoryIds,
                                        CreateUpdateBookViewModel bookToCreate)
        {
            using (var client = new HttpClient())
            {
                var book = new Book()
                {
                    Id            = bookToCreate.Book.Id,
                    Isbn          = bookToCreate.Book.Isbn,
                    Title         = bookToCreate.Book.Title,
                    DatePublished = bookToCreate.Book.DatePublished

                                    //books?authId=?&authId=?&catId=?
                };

                var uriParameters = GetAuthorsCategoriesUri(AuthorIds.ToList(), CategoryIds.ToList());

                client.BaseAddress = new Uri("http://localhost:60039/api/");
                var responseTask = client.PostAsJsonAsync($"books?{uriParameters}", book);
                responseTask.Wait();

                var result = responseTask.Result;

                if (result.IsSuccessStatusCode)
                {
                    var readTaskNewBook = result.Content.ReadAsAsync <Book>();
                    readTaskNewBook.Wait();

                    var newBook = readTaskNewBook.Result;

                    TempData["SuccessMessage"] = $"Book {book.Title} was successfully created.";
                    return(RedirectToAction("GetBookById", new { bookId = newBook.Id }));
                }

                if ((int)result.StatusCode == 422)
                {
                    ModelState.AddModelError("", "ISBN already Exists!");
                }
                else
                {
                    ModelState.AddModelError("", "Error! Book not created!");
                }
            }

            var authorList   = new AuthorsList(_authorRepository.GetAuthors().ToList());
            var categoryList = new CategoriesList(_categoryRepository.GetCategories().ToList());

            bookToCreate.AuthorSelectListItems   = authorList.GetAuthorsList(AuthorIds.ToList());
            bookToCreate.CategorySelectListItems = categoryList.GetCategoriesList(CategoryIds.ToList());
            bookToCreate.AuthorIds   = AuthorIds.ToList();
            bookToCreate.CategoryIds = CategoryIds.ToList();

            return(View(bookToCreate));
        }
Пример #6
0
        public IActionResult Edit(List <int> authorIds, List <int> categoryIds,
                                  CreateUpdateBookViewModel bookToUpdate)
        {
            using (var client = new HttpClient())
            {
                var bookDto = new Book()
                {
                    Id          = bookToUpdate.Book.Id,
                    Title       = bookToUpdate.Book.Title,
                    Isbn        = bookToUpdate.Book.Isbn,
                    DatePublish = bookToUpdate.Book.DatePublish
                };

                var uriParameters = GetAuthorsCategoriesUri(authorIds.ToList(), categoryIds.ToList());

                client.BaseAddress = new Uri("http://localhost:5000/api/");
                var responseTask = client.PutAsJsonAsync($"books/{bookDto.Id}?{uriParameters}", bookDto);
                responseTask.Wait();

                var result = responseTask.Result;

                if (result.IsSuccessStatusCode)
                {
                    TempData["SuccessMessage"] = $"Book {bookDto.Title} was successfully updated.";
                    return(RedirectToAction("GetBookById", new { bookId = bookDto.Id }));
                }

                if ((int)result.StatusCode == 422)
                {
                    ModelState.AddModelError("", "ISBN already exists!");
                }

                else
                {
                    ModelState.AddModelError("", "Error! Book not updated.");
                }
            }

            var authorList   = new AuthorsList(authorRepository.GetAuthors().ToList());
            var categoryList = new CategoriesList(categoryRepository.GetCategories().ToList());

            bookToUpdate.AuthorSelectListItems   = authorList.GetAuthorsList(authorIds.ToList());
            bookToUpdate.CategorySelectListItems = categoryList.GetCategories(categoryIds.ToList());
            bookToUpdate.AuthorIds   = authorIds.ToList();
            bookToUpdate.CategoryIds = categoryIds.ToList();

            return(View(bookToUpdate));
        }
Пример #7
0
        private void Initialize()
        {
            addBookPresenter = new AddBookPresenter(libraryPresenter);
            addBookPresenter.CompleteAuthorList(comboBoxAuthors);
            addBookPresenter.CompleteCategoriesList(comboBoxCategiries);
            authorList = new AuthorsList(libraryPresenter);
            categoriesListControler = new CategoriesList(libraryPresenter);
            AuthorListPresenter AuthorPresenter = new AuthorListPresenter(libraryPresenter, authorList);

            panelAuthorControl.Controls.Add(authorList);
            panelCategoryControler.Controls.Add(categoriesListControler);



            textBoxSelectedAuthors.AutoSize = true;
        }
Пример #8
0
        public IActionResult UpdateBook(int bookId)
        {
            var bookDto      = _bookRepository.GetBookById(bookId);
            var authorList   = new AuthorsList(_authorRepository.GetAuthors().ToList());
            var categoryList = new CategoriesList(_categoryRepository.GetCategories().ToList());

            var bookViewBook = new CreateUpdateBookViewModel
            {
                Book = bookDto,
                AuthorSelectListItems = authorList.GetAuthorList(_authorRepository.GetAuthorOfABook(bookId)
                                                                 .Select(a => a.Id).ToList()),
                CategoriesSelectListItems = categoryList.GetCategoryList(_categoryRepository.GetAllCategoriesOfABook(bookId)
                                                                         .Select(c => c.Id).ToList())
            };

            return(View(bookViewBook));
        }
Пример #9
0
        public IActionResult Edit(int bookId)
        {
            var bookDto     = bookRepository.GetBookById(bookId);
            var authorDto   = new AuthorsList(authorRepository.GetAuthors().ToList());
            var categoryDto = new CategoriesList(categoryRepository.GetCategories().ToList());

            var bookViewModel = new CreateUpdateBookViewModel()
            {
                Book = bookDto,
                AuthorSelectListItems = authorDto.GetAuthorsList(authorRepository.GetAllAuthorsFromBook(bookId).
                                                                 Select(a => a.Id).ToList()),
                CategorySelectListItems = categoryDto.GetCategories(categoryRepository.GetCategoriesFromBook(bookId).
                                                                    Select(a => a.Id).ToList())
            };

            return(View(bookViewModel));
        }
Пример #10
0
        private void DataGrid_Loaded()
        {
            DBClass.openConnection();
            DBClass.sql             = "select * from authors";
            DBClass.cmd.CommandType = CommandType.Text;
            DBClass.cmd.CommandText = DBClass.sql;

            DBClass.da = new SqlDataAdapter(DBClass.cmd);
            DBClass.dt = new DataTable();
            DBClass.da.Fill(DBClass.dt);

            // wyciągamy dane
            int i = 0;
            int j = 0;

            AuthorsList.Clear();
            using (SqlDataReader reader = DBClass.cmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    for (j = 0; j <= reader.FieldCount - 1; j++) // Looping throw colums
                    {
                        data[j] = reader.GetValue(j).ToString();
                    }
                    AuthorsList.Add(new AuthorModel
                    {
                        Id = Int32.Parse(data[0]),
                        FirstNameAuthor = data[1],
                        LastNameAuthor  = data[2]
                    });
                }
            }
            DBClass.closeConnection();

            try
            {
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message);
            }
        }
Пример #11
0
        public IActionResult CreateBook()
        {
            var authors    = authorRepository.GetAuthors();
            var categories = categoryRepository.GetCategories();

            if (authors.Count() <= 0 || categories.Count() <= 0)
            {
                ModelState.AddModelError("", "Some kind or error getting authors or categories");
            }

            var authorList   = new AuthorsList(authors.ToList());
            var categoryList = new CategoriesList(categories.ToList());

            var createUpdateBook = new CreateUpdateBookViewModel {
                AuthorSelectListItems   = authorList.GetAuthorsList(),
                CategorySelectListItems = categoryList.GetCategories()
            };

            return(View(createUpdateBook));
        }
        public void UploadDocumentParams(Document document)
        {
            this.document = document;

            DocumentName         = document.name;
            DocumentNumber       = document.number;
            SelectedDocumentType = DocumentTypesList.First(d => d.id == document.type);
            SelectedBroker       = BrokersList.First(b => b.ShortName == document.broker);

            if (CompaniesStorageList.Count(c => c.name.ToLower().Contains(document.company.ToLower())) > 0)
            {
                SelectedCompany = CompaniesStorageList.First(c => c.name.ToLower().Contains(document.company.ToLower()));
            }

            SearchCompanyTxt = document.company;
            SelectedAuthor   = AuthorsList.FirstOrDefault(a => a.name == document.author);

            if (SelectedAuthor == null)
            {
                SelectedAuthor = AuthorsList.First(a => a.name.ToLower().Contains("не наз"));
            }

            DocumentDate        = document.createdDate;
            DocumentDescription = document.description;

            if (CurrentPresentation == PresentationEnum.Archive)
            {
                DocumentYear         = document.year;
                DocumentCase         = document.case_;
                DocumentVolume       = document.volume;
                DocumentSerialNumber = document.serialNumber == null ? 0 : (int)document.serialNumber;
            }

            AttachedDocument = DataManagerService.Instanse().ReadDocumentLink(document.id);

            if (!string.IsNullOrEmpty(AttachedDocument))
            {
                IsAttach = true;
            }
        }
Пример #13
0
        public void testBookService()
        {
            BookServiceUtilJSON bookservice = new BookServiceUtilJSON("bookserviceaseece.azurewebsites.net", "", "api");
            //Test Author metoder
            AuthorsList alist = bookservice.GetAuthors();
            Author      a     = new Author()
            {
                Id = 2
            };

            a = bookservice.GetAuthor(a);
            Author ath = bookservice.GetAuthor(a);

            ath.Name = "Peter Petersen";
            ath      = bookservice.PostAuthor(ath);
            ath.Name = ath.Name + "Nielsen";
            bookservice.PutAuthor(ath);//No return of data as the copi comes from Requester/Client
            ath = bookservice.DeleteAuthor(ath);

            //Test Book metoder
            Book abook = new Book()
            {
                Author = a, AuthorId = a.Id, Genre = "Vrøvl og Snak", Price = 45, Title = "Det dur bare", Year = 2016
            };
            Book nbook = bookservice.PostBook(abook);

            BooksList bkl = bookservice.GetBooks();
            //System.Console.WriteLine("Bog der skal slette indtast ID:");
            //int i = Int32.Parse(System.Console.ReadLine());

            Book bk = new Book()
            {
                Id = nbook.Id
            };
            Book gbk = bookservice.GetBook(bk);

            gbk.Title = gbk.Title + " Extra Tekst";
            bookservice.PutBook(gbk);
            bookservice.DeleteBook(gbk);
        }
Пример #14
0
        /// <summary>
        /// This method adds all the article info to the entry
        /// </summary>
        /// <param name="showEntryData">A flag that states whether or not to add the entry data to the XML</param>
        /// <param name="showPageAuthors">A flag to state whether or not to add the authors list to the XML</param>
        /// <param name="parentNode">The node that you want to insert the article info block</param>
        /// <returns>The node that represents the articleinfo block</returns>
        private XmlNode AddArticleInfo(bool showEntryData, bool showPageAuthors, XmlNode parentNode)
        {
            // Now add the article info block
            XmlNode articleInfoNode = AddElementTag(parentNode, "ARTICLEINFO");

            // Check to see if we are needed to add the entry data
            if (showEntryData)
            {
                AddEntryData(articleInfoNode);
            }

            AddIntElement(articleInfoNode, "FORUMID", _forumID);
            AddIntElement(articleInfoNode, "SITEID", _siteID);

            if (_hiddenStatus > 0)
            {
                AddIntElement(articleInfoNode, "HIDDEN", _hiddenStatus);
            }

            XmlNode modNode = AddIntElement(articleInfoNode, "MODERATIONSTATUS", _moderationStatus);
            AddAttribute(modNode, "ID", _h2g2ID);

            // Add the page authors if we've been asked to
            if (showPageAuthors)
            {
                // Create the authors list and add it to the page
                AuthorsList pageAuthors = new AuthorsList(InputContext, AuthorsList.ArticleType.ARTICLE, _h2g2ID, _editor);
                pageAuthors.CreateListForArticle();
                XmlNode authorsNode = AddElementTag(articleInfoNode, "PAGEAUTHOR");
                AddInside(authorsNode, pageAuthors, "//RESEARCHERS");
                AddInside(authorsNode, pageAuthors, "//EDITOR");
            }

            // Add the date created and last update
            XmlNode createdNode = AddElementTag(articleInfoNode, "DATECREATED");
            createdNode.AppendChild(DnaDateTime.GetDateTimeAsElement(RootElement.OwnerDocument, _dateCreated, true));

            XmlNode updatedNode = AddElementTag(articleInfoNode, "LASTUPDATED");
            updatedNode.AppendChild(DnaDateTime.GetDateTimeAsElement(RootElement.OwnerDocument, _lastUpdated, true));

            // Create the Article crumbtrail
            Category articleCrumbtrail = new Category(InputContext);
            articleCrumbtrail.CreateArticleCrumbtrail(_h2g2ID);
            AddInside(articleInfoNode, articleCrumbtrail, "//CRUMBTRAILS");

            // Insert a related member node and the preprocessed info
            XmlNode relatedMembersNode = AddElementTag(articleInfoNode, "RELATEDMEMBERS");
            AddIntElement(articleInfoNode, "PREPROCESSED", _preProcessed);

            // Create the related clubs
            Category relatedMembers = new Category(InputContext);
            relatedMembers.GetRelatedClubs(_h2g2ID);
            AddInside(relatedMembersNode, relatedMembers, "//RELATEDCLUBS");

            // Create the related articles
            relatedMembers.IncludeStrippedNames = true;
            relatedMembers.GetRelatedArticles(_h2g2ID);
            AddInside(relatedMembersNode, relatedMembers, "//RELATEDARTICLES");

            // Return the new article info node
            return articleInfoNode;
        }
Пример #15
0
 public static void RebuildAuthorsList()
 {
     // TODO: layouts
     AuthorsList.ReplaceEverythingBy(from o in AuthorInformationObjects select o.Author);
 }
Пример #16
0
 public AuthorListPresenter(ILibraryPresenter libraryPresenter, AuthorsList authorsList)
 {
     this.libraryPresenter = libraryPresenter;
     this.authorsList      = authorsList;
 }