Exemple #1
0
 public void LoadBooks(object sender, EventArgs e)
 {
     ActualBorrows  = BookServices.GetActualBorrows(_book.BookId);
     HistoryBorrows = BookServices.GetHistoryBorrows(_book.BookId);
     NotifyOfPropertyChange(() => ActualBorrows);
     NotifyOfPropertyChange(() => HistoryBorrows);
 }
        public void NotFoundBook_DeleteReturnsZero()
        {
            BookServices bookServices = new BookServices(new EmptyBookRepository());
            var          deleteCount  = bookServices.DeleteBook(10);

            Assert.Equal(0, deleteCount);
        }
Exemple #3
0
        public void EditBook_EditBookRecord_BookRecordShouldBeEdited()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase("MDLibrary_EditBook")
                          .Options;

            var context = new ApplicationDbContext(options);

            Seed(context);

            var testBookService = new BookServices(context);

            var bookToChange = context.BookDetails.Where(x => x.ID == 1).First();

            bookToChange.Titel = "This was changed";

            //Assert
            testBookService.UpdateBookDetails(bookToChange);

            var actualResult = context.BookDetails.Where(x => x.ID == 1).First().Titel;

            //Act
            Assert.Equal("This was changed", actualResult);
        }
        public Boolean ShowUserBook(int uid, MainControl mc, TabPage tb)
        {
            List <User_Book> booklist = User_BookServices.GetUserBooks(uid);

            //int i = Convert.ToInt32(booklist[1].book_id);
            //List<Book> book = null;
            if (booklist.Count != 0)
            {
                int         i    = 0;
                List <Book> book = new List <Book>();
                foreach (var b in booklist)
                {
                    book.Add(BookServices.GetById(Convert.ToInt32(booklist[i++].book_id)));
                }
                // = BookServices.CatagorySearch(category);

                foreach (var o in book)
                {
                    IndividualBook ib = new IndividualBook();
                    ib.setData(o, tb);
                    flowLayoutPanel.Controls.Add(ib);
                }

                return(true);
                //MessageBox.Show("Book available.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                //MetroFramework.MetroMessageBox.Show(mc, "No Book available.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //MessageBox.Show("No Book available.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //Console.WriteLine("no book found");
                return(false);
            }
        }
Exemple #5
0
        public void AddMoreCopiesOfBook_AddOneBookToEmptyList_ReturnCountNrOne()
        {
            ////Arrange

            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase("MDLibrary_AddMoreCopies")
                          .Options;

            var context = new ApplicationDbContext(options);

            var expectedResult = 1;

            var testBook = new BookCopy()
            {
                ID            = 1,
                BookDetailsID = 2
            };

            var testBookService = new BookServices(context);

            //Act

            testBookService.AddMoreCopiesOfBook(testBook);

            var actualResult = context.BookCopy.ToList().Count;

            //Assert
            Assert.Equal(expectedResult, actualResult);
        }
Exemple #6
0
        //
        // GET: /Advise/

        /// <summary>
        /// 考试咨讯
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>

        public ActionResult Index(int?id)
        {
            string categoryCode = string.IsNullOrEmpty(Request.QueryString["CategoryCode"])
                ? SystemConst.CategoryCode.Book : Request.QueryString["CategoryCode"];
            string order = string.IsNullOrEmpty(Request.QueryString["order"])
                ? "default" : Request.QueryString["order"];
            string     categoryName = EnterRepository.GetRepositoryEnter().CategoryRepository.LoadEntities(m => m.Code == categoryCode).FirstOrDefault().Name;
            Pagination pagination   = new Pagination();
            int        page         = 1;

            if (id != null)
            {
                page = int.Parse(id.ToString());
            }
            int totalCount = 0;

            pagination.CurrentPageIndex = page;
            var books = BookServices.GetBooks(categoryCode, order, page, pagination.Size, out totalCount);

            pagination.TotalCount = totalCount;
            ViewBag.Order         = order;
            ViewBag.CategoryCode  = categoryCode;
            ViewBag.CategoryName  = categoryName;
            ViewBag.Books         = books;
            ViewBag.Pagination    = pagination;
            return(View());
        }
Exemple #7
0
        public void AddNewBookDetails_AddBookDetailsForReference_ReturnCountOne()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "MDLibrary_AddNewBookDetails")
                          .Options;

            var context = new ApplicationDbContext(options);

            var testBookService = new BookServices(context);

            var expectedResult = 1;

            var testBook = new BookDetails()
            {
                ID       = 1,
                Titel    = "En testboks historia",
                ISBN     = "1234567891012",
                AuthorID = 1
            };

            //Act
            testBookService.AddNewBookDetails(testBook);
            var actualResult = context.BookDetails.ToList().Count;

            //Assert
            Assert.Equal(expectedResult, actualResult);
        }
Exemple #8
0
        private void ShopForm_Load(object sender, EventArgs e)
        {
            var client = ClientServices.ListClient();

            client.Add(new DAL.Model.Client()
            {
                Id        = 0,
                FirstName = "Select client"
            });
            var clientSort = client.OrderBy(x => x.Id).ToList();

            clientCbo.DataSource    = client.OrderBy(x => x.Id).ToList();
            clientCbo.DisplayMember = "FirstName";
            clientCbo.ValueMember   = "Id";


            var books = BookServices.ListBook();

            books.Add(new DAL.Model.Book()
            {
                Id   = 0,
                Name = "Select a book"
            });
            bookCbo.DataSource    = books.OrderBy(x => x.Id).ToList();
            bookCbo.DisplayMember = "Name";
            bookCbo.ValueMember   = "Id";


            // memeberLbl.Text = "Standard";
        }
        public AddBorrowViewModel()
        {
            Users    = UserServices.GetAll();
            AllBooks = BookServices.GetAll();

            BorrowsList = new ObservableCollection <NewBook>();
        }
Exemple #10
0
        public void ShouldCreate()
        {
            var           bookReposiory = new Mock <IBookRepository>();
            IBookServices bookServices  = new BookServices(bookReposiory.Object);

            bookServices.Should().NotBeNull();
        }
        protected async Task HandleValidSubmit()
        {
            if (file != null)
            {
                EditBookModel.PhotoPath = await FileUpload.Upload(file, EditBookModel);
            }

            Mapper.Map(EditBookModel, Book);

            Book result = null;

            if (Book.id != 0)
            {
                result = await BookServices.UpdateBook(Book);
            }
            else
            {
                result = await BookServices.AddBook(Book);
            }

            if (result != null)
            {
                Navigation.NavigateTo("/Books");
            }
        }
        public void NotFoundBook_GetReturnsNull()
        {
            BookServices bookServices = new BookServices(new EmptyBookRepository());
            var          book         = bookServices.GetBookById(10);

            Assert.Null(book);
        }
        protected async override Task OnInitializedAsync()
        {
            Location = await LocationServices.GetLocation(int.Parse(Id));

            Books = (await BookServices.GetBooks()).ToList().Where(e => e.locationId == Location.id);

            await CountBooksNumber();
        }
Exemple #14
0
 public Application()
 {
     _editionServices = new EditionServices();
     _userServices    = new UserServices();
     _domainServices  = new DomainServices();
     _bookServices    = new BookServices();
     _borrowServices  = new BorrowServices();
 }
Exemple #15
0
        public void Throw_When_Passed_Book_Is_Null()
        {
            // Arrange
            IBookServices sut      = new BookServices(repository, saveChanges);
            Book          nullBook = null;

            // Act & Assert
            Assert.Throws <ArgumentNullException>(() => sut.DeleteBookById(nullBook));
        }
Exemple #16
0
        // GET: BorrowHistories/Create
        public ActionResult Create()
        {
            BorrowViewModel borrowViewModel = new BorrowViewModel();

            borrowViewModel.Students = StudentService.GetStudentList();
            borrowViewModel.Books    = BookServices.GetBooksList();

            return(View(borrowViewModel));
        }
Exemple #17
0
 public BookDetailsViewModel(BookDTO book)
 {
     _book                    = book;
     ActualBorrows            = BookServices.GetActualBorrows(book.BookId);
     HistoryBorrows           = BookServices.GetHistoryBorrows(book.BookId);
     dispatcherTimer.Tick    += new EventHandler(LoadBooks);
     dispatcherTimer.Interval = TimeSpan.FromSeconds(10);
     dispatcherTimer.Start();
 }
        protected async Task ConfirmDelete_Click(bool deleteConfirmed)
        {
            if (deleteConfirmed)
            {
                await BookServices.DeleteBook(Book.id);

                Navigation.NavigateTo("Books");
            }
        }
Exemple #19
0
        public void CreateBookService_IfParametersAreValid()
        {
            // Arrange & Act
            var dbSetMock       = new Mock <ILibrarySystemEfWrapper <Book> >();
            var saveChangesMock = new Mock <ILibrarySystemEfDbContextSaveChanges>();
            var bookServices    = new BookServices(dbSetMock.Object, saveChangesMock.Object);

            // Assert
            Assert.That(bookServices, Is.Not.Null.And.InstanceOf <BookServices>());
        }
 public CartController(bookstoreContext context,
                       CartServices cartServices,
                       IMapper mapper,
                       BookServices bookServices)
 {
     _context      = context;
     _cartServices = cartServices;
     _mapper       = mapper;
     _bookServices = bookServices;
 }
Exemple #21
0
        public void GetAll_Should_Return_Proper_Collection()
        {
            // Arrange
            IBookServices sut = new BookServices(repository, saveChanges);

            // Act
            IQueryable <Book> result = sut.GetAllBooks();

            // Assert
            Assert.AreEqual(result, dbContext.Books);
        }
Exemple #22
0
 public BookController(
     IProxy <BookModel> bookProxy,
     IProxy <EditorialModel> editorialProxy,
     IOptionsSnapshot <BookServices> bookSnapshot,
     IOptionsSnapshot <EditorialServices> editorialSnapshot)
 {
     this.bookProxy         = bookProxy;
     this.editorialProxy    = editorialProxy;
     this.bookServices      = bookSnapshot.Value;
     this.editorialServices = editorialSnapshot.Value;
 }
 public BooksController(BookServices bookServices,
                        bookstoreContext bookstoreContext,
                        IMapper mapper,
                        ImageServices imageServices
                        )
 {
     _bookServices  = bookServices;
     _context       = bookstoreContext;
     _mapper        = mapper;
     _imageServices = imageServices;
 }
Exemple #24
0
        public void InitCombo()
        {
            for (long i = 0; i < 21; i++)
            {
                cboRating.Items.Add(i);
            }

            cboMedia.ItemsSource    = MediaServices.GetNames();
            cboLanguage.ItemsSource = LanguageServices.GetLanguages();
            cboEditor.DataContext   = PublisherServices.GetPublishers("App_Editor");
            cboFormat.ItemsSource   = BookServices.GetFormats();
        }
 public CartRedisController(bookstoreContext context,
                            IConnectionMultiplexer connectionMultiplexer,
                            IMapper mapper,
                            CartServices cartServices,
                            BookServices bookServices)
 {
     database      = connectionMultiplexer.GetDatabase();
     _mapper       = mapper;
     _context      = context;
     _cartServices = cartServices;
     _bookServices = bookServices;
 }
 public void Filter()
 {
     ActualPage              = 0;
     ToSendFromDate          = FromDate;
     ToSendToDate            = ToDate;
     ToSendSelectedBookGenre = SelectedBookGenre;
     ToSendSelectedTitle     = SelectedTitle;
     NotifyOfPropertyChange(() => ShowActualPage);
     numberOfBooks           = BookServices.NumberOfBooks(ToSendSelectedTitle, ToSendSelectedBookGenre);
     NumberOfBorrowsPerTitle = BorrowServices.NumberOfBorrowsPerTitle(ToSendSelectedTitle, ToSendSelectedBookGenre, ToSendFromDate, ToSendToDate, ActualPage, PageSize);
     NotifyOfPropertyChange(() => NumberOfBorrowsPerTitle);
 }
Exemple #27
0
        public FormDocumentView(List <string> datos, long idDocument, string tipoDocumento)
        {
            _idDocument       = idDocument;
            _datos            = datos;
            _tipoDocumento    = tipoDocumento;
            _documentServices = new DocumentServices();
            _tesisServices    = new TesisServices();
            _bookServices     = new BookServices();
            _articleServices  = new ArticleServices();
            InitializeComponent();

            CreateForm();
        }
        public void AddNewBook()
        {
            string x = BookServices.Add(Title, Author, ReleaseDate, ISBN, Count, SelectedBookGenre);

            if (x == null)
            {
                TryClose();
            }
            else
            {
                Error = x;
            }
        }
Exemple #29
0
        public void Setup()
        {
            options = new DbContextOptionsBuilder <FancyLibraryContext>()
                      .UseInMemoryDatabase(databaseName: "fancy_library_get_all_books")
                      .Options;

            db = new FancyLibraryContext(options);

            bookServices = new BookServices(db);

            db.Books.AddRange(CreateInMemoryDb());
            db.SaveChanges();
        }
Exemple #30
0
        public void Remove_Book_With_Exact_Id()
        {
            // Arrange
            IBookServices sut = new BookServices(repository, saveChanges);

            sut.AddBook(book);

            // Act
            sut.DeleteBookById(book.Id);

            // Assert
            CollectionAssert.DoesNotContain(dbContext.Books, book);
        }