public async Task Add()
        {
            if (UserInfoVisibility)
            {
                await Managers.UserManager.RegisterAsync(Login, Password, FirstName, LastName, PhoneNumber);
            }
            if (BookInfoVisibility)
            {
                var dimensions = new BookDimensions(Length, Width, Height);
                var book       = new Book(BookName, BookISBN, Amount, BookISBN, Description, Author, Publisher, Language, Category, ReleaseDate, Pages, Price, Rating, Weight, dimensions, true);
                await Managers.UnitOfWork.Books.AddAsync(book);
            }
            if (RentInfoVisibility)
            {
                var readers = Managers.UnitOfWork.Users.FindByCondition(u => u.Id == User_Id);
                if (readers.Count() == 0)
                {
                    throw new KeyNotFoundException("User not found.");
                }

                var reader = readers.Single();
                var books  = Managers.UnitOfWork.Books.FindByCondition(b => b.Id == Book_Id);
                if (books.Count() == 0)
                {
                    throw new KeyNotFoundException("Book not found.");
                }

                var book = books.Single();

                var rent = new Rent(reader, book, DateTime.Now.AddDays(7));
                await Managers.UnitOfWork.Rents.AddAsync(rent);
            }

            TryClose(true);
        }
Exemplo n.º 2
0
        public BookDetailsBLL()
        {
            _description = new BookDetailsBLL.BookDescription();
            _publishInfo = new BookDetailsBLL.BookPublishInfo();
            _dimensions = new BookDimensions();

            AuthorIDs = new List<int>();
        }