void AddBook()
        {
            AddEditBookViewModel newBook = new AddEditBookViewModel("Add", BookType.None);
            AddEditBook          newWin  = new AddEditBook();

            newWin.DataContext = newBook;
            newWin.ShowDialog();

            if (newWin.DialogResult == true)
            {
                BookProduct bookToAdd = new BookProduct();
                bookToAdd.BookID      = AllBooks.Count + 1;
                bookToAdd.BookType    = newBook.AddEditItem.BookType;
                bookToAdd.BookName    = newBook.AddEditItem.BookName;
                bookToAdd.BookWriter  = newBook.AddEditItem.BookWriter;
                bookToAdd.PublishYear = newBook.AddEditItem.PublishYear;
                switch (newBook.AddEditItem.BookType)
                {
                case BookType.EBook:
                    (bookToAdd as EbookItem).NumOfDownloads = (newBook.AddEditItem as EbookItem).NumOfDownloads;
                    foreach (var item in (newBook.AddEditItem as EbookItem).LanguagesTranslations)
                    {
                        (bookToAdd as EbookItem).LanguagesTranslations.Add(item);
                    }
                    break;

                case BookType.Printed:
                    (bookToAdd as PrintedItem).NumOfCopied = (newBook.AddEditItem as PrintedItem).NumOfCopied;
                    (bookToAdd as PrintedItem).BookWeight  = (newBook.AddEditItem as PrintedItem).BookWeight;
                    (bookToAdd as PrintedItem).IsAvilable  = (newBook.AddEditItem as PrintedItem).IsAvilable;
                    break;
                }
                AllBooks.Add(bookToAdd);
            }
        }
Beispiel #2
0
        public void AddBook()
        {
            bool result = _navigationService.GetWindow <BookDetailsViewModel>().ShowWindowModal();

            if (result)
            {
                //Adding a new books to list
                Book newBook = null;
                using (var dbService = _dbServiceManager.GetService())
                {
                    var books = dbService.Books.GetAll();

                    foreach (var b in books.OrderByDescending(cli => cli.Id))
                    {
                        if (AllBooks.Any(book => book.Id == b.Id))
                        {
                            break;
                        }
                        else
                        {
                            if (newBook == null)
                            {
                                newBook = b;
                            }
                            AllBooks.Add(b);
                        }
                    }
                }

                Books        = new BindableCollection <Book>(AllBooks);
                SelectedBook = newBook;
            }
        }
 public BookLibrary()
 {
     AllBooks.Add(new Book(1, "Hamlet", "Bill Shakespeare", 1602));
     AllBooks.Add(new Book(2, "Moby Dick", "Hermit Melville", 1851));
     AllBooks.Add(new Book(3, "Frankenstein", "Merry Shelly", 1818));
     AllBooks.Add(new Book(4, "Lord of the Rings", "J.R.R. Token", 1954));
     AllBooks.Add(new Book(5, "Harry Potter", "J.K. Bowling", 1998));
 }
Beispiel #4
0
 public void ShowAllBooksMethod()
 {
     using (Model1 context = new Model1())
     {
         foreach (Book a in context.Books)
         {
             AllBooks.Add(a.BookName);
         }
     }
 }
        void bRemove_Click(object sender, EventArgs e)
        {
            var request = gvResult.GetSelectedRow <Request>();

            request.Do(r => {
                AllBooks.Add(r.Book);
                AllBooks = AllBooks.OrderBy(b => b.Name).ToList();
                gcBooks.Bind(AllBooks);
                RemoveRequest(r);
            });
        }
Beispiel #6
0
            public Book AddBook(string name, string catagory, string readingStatus, List <string> tags)
            {
                Book book = new Book(name, catagory, readingStatus, tags);

                AllBooks.Add(book);
                if (addBookEvent != null)
                {
                    addBookEvent(book);
                }
                return(book);
            }
Beispiel #7
0
        public void AddBookMethod()
        {
            AllBooks.Add(BookName);
            Book NewBook = new Book();

            NewBook.BookName = BookName;
            using (Model1 context = new Model1())
            {
                context.Books.Add(NewBook);
                context.SaveChanges();
            }
        }
Beispiel #8
0
 public Book AddBook(Book book)
 {
     if (GetBook(book.Name) != null)
     {
         return(null);
     }
     AllBooks.Add(book);
     if (addBookEvent != null)
     {
         addBookEvent(book);
     }
     return(book);
 }
Beispiel #9
0
        public async override Task LoadAsync(Guid id)
        {
            SelectedItem = await Repository.GetSelectedAsync(id) ?? new Series();

            Id = id;

            if (Id != default)
            {
                TabTitle = SelectedItem.Name;
                Name     = SelectedItem.Name;
            }
            else
            {
                this.SwitchEditableStateExecute();
            }

            await PopulateAllBooksCollection();

            SetDefaultSeriesPictureIfNoneSet();

            SelectedItem.PropertyChanged += (s, e) =>
            {
                SetChangeTracker();
            };

            void SetDefaultSeriesPictureIfNoneSet()
            {
                if (SelectedItem.PicturePath is null)
                {
                    SelectedItem.PicturePath = FileExplorerService.GetImagePath();
                }
            }

            async Task PopulateAllBooksCollection()
            {
                AllBooks.Clear();
                foreach (var item in await GetBookList())
                {
                    AllBooks.Add(item);
                }
            }
        }
Beispiel #10
0
        public Page()
        {
            InitializeComponent();
            //<snippet4>
            //You can add items to your collection
            AllBooks.Add(new Book("4458907683", "Training Your Dog",
                                  new DateTime(2000, 2, 8), 44.25));
            AllBooks.Add(new Book("0446675385", "Good Owners, Great Dogs",
                                  new DateTime(1999, 9, 1), 15.99));
            //Set the data context for the list of books
            MyBooks.DataContext = AllBooks;

            //</snippet4>

            //<snippet6>
            this.MyBooks.SelectionChanged +=
                new SelectionChangedEventHandler(MyBooks_SelectionChanged);
            MyBooks.SelectedIndex = 0;
            //</snippet6>
        }
Beispiel #11
0
        public async override Task LoadAsync(Guid id)
        {
            try
            {
                var series = await domainService.Repository.GetSelectedAsync(id) ?? new Series();

                SelectedItem = CreateWrapper(series);

                SelectedItem.PropertyChanged += (s, e) =>
                {
                    if (!HasChanges)
                    {
                        HasChanges = domainService.Repository.HasChanges();
                    }
                    if (e.PropertyName == nameof(SelectedItem.HasErrors))
                    {
                        ((DelegateCommand)SaveItemCommand).RaiseCanExecuteChanged();
                    }
                    if (e.PropertyName == nameof(SelectedItem.Name))
                    {
                        TabTitle = SelectedItem.Name;
                    }
                };
                ((DelegateCommand)SaveItemCommand).RaiseCanExecuteChanged();

                Id = id;

                if (Id != default)
                {
                    TabTitle = SelectedItem.Name;
                }
                else
                {
                    this.SwitchEditableStateExecute();
                    SelectedItem.Name = "";
                }

                await PopulateAllBooksCollection();

                SetDefaultSeriesPictureIfNoneSet();

                void SetDefaultSeriesPictureIfNoneSet()
                {
                    if (SelectedItem.PicturePath is null)
                    {
                        SelectedItem.PicturePath = FileExplorerService.GetImagePath();
                    }
                }


                async Task PopulateAllBooksCollection()
                {
                    AllBooks.Clear();
                    foreach (var item in await GetBookList())
                    {
                        AllBooks.Add(item);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                logger.Error("Message: {Message}\n\n Stack trace: {StackTrace}\n\n", ex.Message, ex.StackTrace);
            }
        }
Beispiel #12
0
        public void Addbook(ReadingStatus status, string name, ObservableCollection <string> tags, Catagory catagory)
        {
            AllBooks.Add(new Book(status, name, tags, catagory));

            TheSerialiingClass.serialize <Books>(MainWindow.cnfgcs.Path_Save, this);
        }