Example #1
0
        public void Lose()
        {
            if (_state != BookState.ON_LOAN)
                throw new ApplicationException($"Error: Guard against wrong state : {_state}");

            _state = BookState.LOST;
        }
Example #2
0
        public void Repair()
        {
            if (_state != BookState.DAMAGED)
                throw new ApplicationException($"Error: Guard against wrong state : {_state}");

            _state = BookState.AVAILABLE;
        }
Example #3
0
        public void ReturnBook(bool isDamaged)
        {
            if (_state != BookState.ON_LOAN && this._state != BookState.LOST)
                throw new ApplicationException($"Error: Guard against wrong state: {_state}");

            NothingOnLoan();

            this._state = isDamaged ? BookState.DAMAGED : BookState.AVAILABLE;
        }
Example #4
0
        public void Borrow(ILoan loan)
        {
            if (loan == null)
                throw new ArgumentException("Error loan cant be null.");

            if (_state != BookState.AVAILABLE)
                throw new ApplicationException($"Error: Guard against wrong state : {_state}");

            _loan = loan;

            _state = BookState.ON_LOAN;
        }
Example #5
0
 public Book(string author, string title, string callNumber, int bookID)
 {
     if (!sane(author, title, callNumber, bookID))
     {
         throw new ArgumentException("Member: constructor : bad parameters");
     }
     this.author = author;
     this.title = title;
     this.callNumber = callNumber;
     this.id = bookID;
     this.state = BookState.AVAILABLE;
     this.loan = null;
 }
Example #6
0
        public Book([WithKey("Name")]string author, [WithKey("Title")]string title, [WithKey("Number")]string callNumber, int bookId)
        {
            if (string.IsNullOrEmpty(author) 
                || string.IsNullOrEmpty(title) 
                || string.IsNullOrEmpty(callNumber) 
                || bookId <= 0)
                throw new ArgumentException("Error Constructor parameters invalid");

            _author = author;
            _title = title;
            _callNumber = callNumber;
            _id = bookId;
            _state = BookState.AVAILABLE;
        }
Example #7
0
 public void SelectBook(string title, string author, bool hardback, BookState bookState)
 {
     foreach (Book book in bookList)
     {
         if (book.Description.Title == title &&
             book.Description.Author == author &&
             book.Description.Hardback == hardback &&
             book.state == bookState)
         {
             this.activeBook = book;
             return;
         }
     }
     throw new ILibrary.NoSuchBook_Exception();
 }
Example #8
0
        public void AddBookStateTest()
        {
            Book      book2      = new Book("tytuł2", "autor2", CoverType.HardcoverCaseWrap, "gatunek2");
            BookState bookState2 = new BookState(book2, 500, 300);

            DataService.AddBookState(bookState2);
            IEnumerator enumerator = DataService.GetAllBookStatesForBook(book2).GetEnumerator();
            int         size       = 0;

            while (enumerator.MoveNext())
            {
                size++;
                Assert.AreEqual(bookState2, enumerator.Current);
            }
            Assert.AreEqual(1, size);
        }
        public void SetterTest()
        {
            BookState bookState = new BookState(null, 0, 0, 0, null);
            Book      book      = new Book("Tom", "C#Start", 455);

            bookState.Book = book;
            Assert.AreEqual <Book>(book, bookState.Book);
            bookState.Quantity = 15;
            Assert.AreEqual <int>(15, bookState.Quantity);
            bookState.NetPrice = 25.6f;
            Assert.AreEqual <float>(25.6f, bookState.NetPrice);
            bookState.Tax = 10;
            Assert.AreEqual <int>(10, bookState.Tax);
            bookState.Id = "RXX";
            Assert.AreEqual <string>("RXX", bookState.Id);
        }
        public void DeleteBookStateTestException()
        {
            var bookStateToDelete = new BookState()
            {
                DateOfPurchase = new DateTimeOffset(year: 2018, month: 1, day: 24, hour: 15, minute: 29, second: 00, offset: new TimeSpan(1, 0, 0)),
                Book           = new Book()
                {
                    Isbn        = "0000",
                    Title       = "test2",
                    Author      = "testowy",
                    ReleaseYear = 2018
                }
            };

            service.DeleteBookState(bookStateToDelete);
        }
Example #11
0
        public Purchase PurchaseBook(Client client, BookState bookState, int quantity)
        {
            Purchase Purchase = null;

            if (quantity <= bookState.Quantity)
            {
                Purchase            = new Purchase(client, bookState, DateTimeOffset.Now, quantity);
                bookState.Quantity -= quantity;
                DataRepository.AddPurchase(Purchase);
                if (DataRepository.GetClient(client.ClientId) == null)
                {
                    DataRepository.AddClient(client);
                }
            }

            return(Purchase);
        }
        public void AddEventTestException1()
        {
            var bookState = new BookState()
            {
                DateOfPurchase = new DateTimeOffset(year: 2018, month: 1, day: 24, hour: 15, minute: 29, second: 00, offset: new TimeSpan(1, 0, 0)),
                Book           = new Book()
                {
                    Isbn        = "0000",
                    Title       = "test2",
                    Author      = "testowy",
                    ReleaseYear = 2018
                }
            };
            var bookReader = context.bookReaders[0];

            service.AddEvent(bookReader, bookState);
        }
        public void DeleteBookStateTest()
        {
            DataContext        dataContext        = new DataContext();
            ConstantDataFiller constantDataFiller = new ConstantDataFiller();
            DataRepository     dataRepository     = new DataRepository(dataContext, constantDataFiller);

            Book      book      = new Book("Tom", "C#Start", 455);
            BookState bookState = new BookState(book, 10, 23.5f, 23, "ORA");

            dataContext.bookStates.Add(bookState);
            int size1 = dataContext.bookStates.Count();

            Assert.IsTrue(dataContext.bookStates.Contains(bookState));
            dataRepository.DeleteBookState(bookState);
            Assert.AreEqual(dataContext.bookStates.Count, size1 - 1);
            Assert.IsFalse(dataContext.bookStates.Contains(bookState));
        }
        public void RentBookTest()
        {
            Reader    reader1    = new Reader("Artur", "Xinski", 123456987);
            Book      book1      = new Book("111-222-333", "Wojciech Sowa", "Life is life", "Amazing book");
            Book      book2      = new Book("156-879-654", "John Tolkien", "LOTR", "Must have");
            BookState bookState1 = new BookState(book1, true, new System.DateTime(2011, 11, 11));
            BookState bookState2 = new BookState(book2, false, new System.DateTime(1998, 8, 7));


            int amountOfRentedBooks1 = dataService.GetAllReaderEvents(reader1).OfType <BookRent>().Count();

            dataService.RentBook(reader1, bookState1);

            Assert.ThrowsException <InvalidOperationException>(() => dataService.RentBook(reader1, bookState2));
            Assert.IsFalse(bookState1.Available);
            Assert.AreEqual(amountOfRentedBooks1 + 1, dataService.GetAllReaderEvents(reader1).OfType <BookRent>().Count());
        }
Example #15
0
    void OnTriggerEnter2D(Collider2D other)
    {
        RigidbodyController character = other.GetComponent <RigidbodyController>();

        switch (State)
        {
        case BookState.Grounded:
            if (character != null && !character.HasBook())
            {
                State                   = BookState.Held;
                _heldBy                 = other.gameObject;
                transform.parent        = other.transform;
                transform.localPosition = new Vector3(0, 1, 0);
                GetComponent <CircleCollider2D>().enabled = false;
                character.GetBook(this);
            }
            break;

        case BookState.Held:
            break;

        case BookState.Thrown:
            if (character != null)
            {
                if (character.gameObject != _heldBy)
                {
                    character.HitByBook(this);
                    Explode();
                }
            }
            else if (other.GetComponent <BookBehavior>() == null)
            {
                Explode();
            }
            if (transform.position.magnitude > 20)
            {
                Destroy(gameObject);
            }
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
    }
        public void SettersTest()
        {
            Event  saleEvent = new Sale(null, null, new DateTimeOffset(), 0);
            Client client    = new Client("Ala", "Kot", "2234");

            saleEvent.Client = client;
            Assert.AreEqual <Client>(client, saleEvent.Client);
            Book      book      = new Book("J R R Tolkien", "Hobbit", 1);
            BookState bookState = new BookState(book, 8, 45.3f, 10, "XRA");

            saleEvent.BookState = bookState;
            Assert.AreEqual <BookState>(bookState, saleEvent.BookState);
            DateTimeOffset date = new DateTimeOffset(new DateTime(2019, 10, 15));

            saleEvent.Date = date;
            Assert.AreEqual <DateTimeOffset>(date, saleEvent.Date);
            saleEvent.Quantity = 6;
            Assert.AreEqual <int>(6, saleEvent.Quantity);
        }
Example #17
0
    void OnBookStateChange(BookState useBookState)
    {
        switch (useBookState)
        {
        case BookState.none:
            main.SetActive(true);
            _ImageMove.ResetPos();
            isPlaying = false;
            break;

        case BookState.pageOne:
            Debug.Log("第一页");
            if (isPlaying)
            {
                StartCoroutine(pageone1());
            }
            else
            {
                StartCoroutine(pageone());
            }
            break;

        case BookState.pageOneHalf:
            Debug.Log("第一页半");
            StartCoroutine(pageonehalf());
            break;

        case BookState.pageTwo:
            Debug.Log("第二页");
            pagetwo();
            break;

        case BookState.pageThree:
            Debug.Log("第三页");
            StartCoroutine(pagethree());
            break;

        case BookState.pageFour:
            StartCoroutine(pagefour());
            Debug.Log("第四页");
            break;
        }
    }
Example #18
0
    public void ChangeBookState(BookState state)
    {
        if (!m_IsABook)
        {
            return;
        }
        m_CurrentBookState = state;

        switch (state)
        {
        case BookState.Normal:
            Reset();
            break;

        case BookState.Smoking:;
            m_IsOnFire          = false;
            m_HasStartedSmoking = true;
            m_SmokeEmitter      = (GameObject)Instantiate(m_SmokeEmitterObject, transform.position, Quaternion.identity);
            m_SmokeEmitter.transform.position = new Vector3(
                m_SmokeEmitter.transform.position.x + GetComponent <SpriteRenderer>().bounds.size.x / 2,
                m_SmokeEmitter.transform.position.y + GetComponent <SpriteRenderer>().bounds.size.y / 2,
                -0.1f);
            break;

        case BookState.OnFire:
            m_IsOnFire         = true;
            m_SmallFireEmitter = (GameObject)Instantiate(m_SmallFireEmitterObject, transform.position, Quaternion.identity);
            m_SmallFireEmitter.transform.position = new Vector3(
                m_SmallFireEmitter.transform.position.x + GetComponent <SpriteRenderer>().bounds.size.x / 2,
                m_SmallFireEmitter.transform.position.y + GetComponent <SpriteRenderer>().bounds.size.y / 2,
                -0.2f);
            break;

        case BookState.Inferno:
            m_LargeFireEmitter = (GameObject)Instantiate(m_LargeFireEmitterObject, transform.position, Quaternion.identity);
            m_LargeFireEmitter.transform.position = new Vector3(
                m_LargeFireEmitter.transform.position.x + GetComponent <SpriteRenderer>().bounds.size.x / 2,
                m_LargeFireEmitter.transform.position.y + GetComponent <SpriteRenderer>().bounds.size.y / 2,
                -0.2f);
            break;
        }
    }
        public void DeleteEventTest()
        {
            DataContext        dataContext        = new DataContext();
            ConstantDataFiller constantDataFiller = new ConstantDataFiller();
            DataRepository     dataRepository     = new DataRepository(dataContext, constantDataFiller);

            Client         client    = new Client("Ala", "Kot", "2234");
            Book           book      = new Book("J R R Tolkien", "Hobbit", 1);
            DateTimeOffset date      = new DateTimeOffset(new DateTime(2019, 10, 15));
            BookState      bookState = new BookState(book, 5, 45.3f, 10, "XRA");
            Event          saleEvent = new Sale(client, bookState, date, 2);

            dataContext.events.Add(saleEvent);
            int size1 = dataContext.events.Count();

            Assert.IsTrue(dataContext.events.Contains(saleEvent));
            dataRepository.DeleteEvent(saleEvent);
            Assert.AreEqual(dataContext.events.Count, size1 - 1);
            Assert.IsFalse(dataContext.events.Contains(saleEvent));
        }
        public void ObservableCollectionEventTest()
        {
            DataRepository dataRepository = new DataRepository(new DataContext(), new ConstantDataFiller());
            Client         client         = dataRepository.GetAllClients().First();
            BookState      bookState      = dataRepository.GetAllBookStates().First();

            bool  happend  = false;
            Event purchase = new Purchase(client, bookState, DateTimeOffset.Now, 2);

            dataRepository.EventAdded += (object sender, EventArgs ags) => happend = true;
            dataRepository.AddEvent(purchase);

            Assert.IsTrue(happend);

            happend = false;
            dataRepository.EventRemoved += (object sender, EventArgs ags) => happend = true;
            dataRepository.DeleteEvent(purchase);

            Assert.IsTrue(happend);
        }
        public void GetAllBookEventsBetweenDatesTest()
        {
            Reader    reader     = new Reader("Artur", "Xinski", 123456987);
            Book      book       = new Book("111-222-333", "Wojciech Sowa", "Life is life", "Amazing book");
            BookState bookState1 = new BookState(book, true, new System.DateTime(2011, 11, 11));
            BookState bookState2 = new BookState(book, true, new System.DateTime(1998, 8, 7));

            DateTime firstDate = DateTime.Now;

            Assert.AreEqual(0, dataService.GetAllBookEventsBetweenDates(firstDate, DateTime.Now).Count());

            dataService.RentBook(reader, bookState1);
            Assert.AreEqual(1, dataService.GetAllBookEventsBetweenDates(firstDate, DateTime.Now).Count());

            dataService.RentBook(reader, bookState2);
            Assert.AreEqual(2, dataService.GetAllBookEventsBetweenDates(firstDate, DateTime.Now).Count());

            dataService.ReturnBook(reader, bookState1);
            Assert.AreEqual(3, dataService.GetAllBookEventsBetweenDates(firstDate, DateTime.Now).Count());
        }
Example #22
0
        public void AddEvent(BookReader bookReader, BookState bookState)
        {
            // check if the book is available && if bookReader exists
            if (bookState.Available && repository.GetAllBookReaders().Contains(bookReader))
            {
                Event e = new Event()
                {
                    BookReader = bookReader,
                    BookState  = bookState,
                    BorrowDate = DateTimeOffset.Now
                };

                // set book state's avaiable value to false
                bookState.Available = false;
                repository.AddEvent(e);
            }
            else
            {
                throw new InvalidOperationException("Nie można wypożyczyć podanej książki lub podany czytelnik nie istnieje");
            }
        }
Example #23
0
        public void CannotRemoveBookStateWhoseBookIsBorrowedTest()
        {
            BookState bookState = null;

            foreach (BookState bs in dataRepository.GetAllBookState())
            {
                if (!bs.Available)
                {
                    bookState = bs;
                    break;
                }
            }
            if (bookState != null)
            {
                Assert.ThrowsException <InvalidOperationException>(() => dataRepository.DeleteBookState(bookState));
            }
            else
            {
                Assert.Inconclusive("No state with borrowed book so cannot check if state with borrowed book can be deleted");
            }
        }
Example #24
0
        public string GetState(BookState state)
        {
            switch (state)
            {
            case BookState.Normal:
                return("可借阅");

            case BookState.Readonly:
                return("馆内阅览");

            case BookState.Borrowed:
                return("已借出");

            case BookState.ReBorrowed:
                return("被续借");

            case BookState.Appointed:
                return("被预约");

            default:
                return("");
            }
        }
Example #25
0
    public void Throw(Vector3 fromPosition, bool keep, params Vector3[] directions)
    {
        BookBehavior newBookBehavior = null;

        if (keep)
        {
            newBookBehavior         = Instantiate(gameObject, transform.parent).GetComponent <BookBehavior>();
            newBookBehavior.State   = BookState.Held;
            newBookBehavior._heldBy = _heldBy;
            newBookBehavior.Kind    = Kind;
        }
        if (directions[0].sqrMagnitude > 0)
        {
            transform.parent = null;
            _throwDirection  = directions[0].normalized;
            State            = BookState.Thrown;
            GetComponent <CircleCollider2D>().enabled = true;
            SetHeight(ThrowHeight);
            _verticalVelocity = InitialVerticalVelocity;
            _heldBy.GetComponent <RigidbodyController>().LoseBook();
            for (int i = 1; i < directions.Length; i++)
            {
                BookBehavior extraThrownBookBehavior = Instantiate(gameObject).GetComponent <BookBehavior>();
                extraThrownBookBehavior._throwDirection = directions[i].normalized;
                extraThrownBookBehavior.State           = BookState.Thrown;
                extraThrownBookBehavior.GetComponent <CircleCollider2D>().enabled = true;
                extraThrownBookBehavior.SetHeight(ThrowHeight);
                extraThrownBookBehavior._heldBy           = _heldBy;
                extraThrownBookBehavior._verticalVelocity = InitialVerticalVelocity;
                extraThrownBookBehavior.Kind = Kind;
            }
        }
        if (keep)
        {
            _heldBy.GetComponent <RigidbodyController>().GetBook(newBookBehavior);
        }
    }
Example #26
0
 public void ChangePrice(BookState bookState, int newPrice)
 {
     DataRepository.UpdateBookState(bookState.BookStateId, new BookState(bookState.Book, newPrice, bookState.Quantity));
 }
Example #27
0
 public void Dispose()
 {
     if (_state != BookState.DAMAGED && _state != BookState.LOST && _state != BookState.AVAILABLE )
         throw new ApplicationException($"Error: Guard against wrong state : {_state}");
     _state = BookState.DISPOSED;
 }
Example #28
0
 public void Repair()
 {
     if (!(state == BookState.DAMAGED))
     {
         throw new ApplicationException(String.Format("Illegal operation in state : {0}", state));
     }
     state = BookState.AVAILABLE;
 }
Example #29
0
 public void ReturnBook(bool damaged)
 {
     if (!(state == BookState.ON_LOAN || state == BookState.LOST))
     {
         throw new ApplicationException(String.Format("Illegal operation in state : {0}", state));
     }
     loan = null;
     if (damaged)
     {
         state = BookState.DAMAGED;
     }
     else
     {
         state = BookState.AVAILABLE;
     }
 }
Example #30
0
 public void Borrow(ILoan loan)
 {
     if (loan == null)
     {
         throw new ArgumentException("Book: borrow : Bad parameter: loan cannot be null");
     }
     if (!(state == BookState.AVAILABLE))
     {
         string mesg = String.Format("Illegal operation in state : {0}", state);
         throw new ApplicationException(mesg);
     }
     this.loan = loan;
     state = BookState.ON_LOAN;
 }
Example #31
0
 public void Dispose()
 {
     if (!(state == BookState.AVAILABLE ||
           state == BookState.DAMAGED ||
           state == BookState.LOST))
     {
         throw new ApplicationException(String.Format("Illegal operation in state : {0}", state));
     }
     state = BookState.DISPOSED;
 }
Example #32
0
        public void AddBookState(Book book, bool available, DateTime buyingTime)
        {
            BookState bookState = new BookState(book, available, buyingTime);

            IDataRepository.AddBookState(bookState);
        }
Example #33
0
 public void Lose()
 {
     if (!(state == BookState.ON_LOAN))
     {
         throw new ApplicationException(String.Format("Illegal operation in state : {0}", state));
     }
     state = BookState.LOST;
 }
        public override void Fill(ref DataContext context)
        {
            var bookReaders = context.bookReaders;
            var books       = context.books;
            var events      = context.events;
            var bookStates  = context.bookStates;

            // create book reader objects
            BookReader reader1 = new BookReader()
            {
                Age       = 30,
                FirstName = "Sławomir",
                LastName  = "Desperski",
                Telephone = "343245634"
            };
            BookReader reader2 = new BookReader()
            {
                Age       = 50,
                FirstName = "Jacek",
                LastName  = "Goc",
                Telephone = "5346345"
            };
            BookReader reader3 = new BookReader()
            {
                Age       = 45,
                FirstName = "Mirosław",
                LastName  = "Saniewski",
                Telephone = "465432654"
            };

            // initialize book reader list
            bookReaders.Add(reader1);
            bookReaders.Add(reader2);
            bookReaders.Add(reader3);

            // create book objects
            Book book1 = new Book()
            {
                Isbn        = "9788380751606",
                Title       = "Behawiorysta",
                Author      = "Remigiusz Mróz",
                ReleaseYear = 2016
            };
            Book book2 = new Book()
            {
                Isbn        = "9788380750210",
                Title       = "Ekspozycja",
                Author      = "Remigiusz Mróz",
                ReleaseYear = 2015
            };
            Book book3 = new Book()
            {
                Isbn        = "9788380750722",
                Title       = "Przewieszenie",
                Author      = "Remigiusz Mróz",
                ReleaseYear = 2016
            };
            Book book4 = new Book()
            {
                Isbn        = "9788380751026",
                Title       = "Trawers",
                Author      = "Remigiusz Mróz",
                ReleaseYear = 2016
            };
            Book book5 = new Book()
            {
                Isbn        = "9788327154590",
                Title       = "Enklawa",
                Author      = "Ove Logmansbo",
                ReleaseYear = 2016
            };
            Book book6 = new Book()
            {
                Isbn        = "9788327155825",
                Title       = "Połów",
                Author      = "Ove Logmansbo",
                ReleaseYear = 2016
            };
            Book book7 = new Book()
            {
                Isbn        = "9788327155917",
                Title       = "Prom",
                Author      = "Ove Logmansbo",
                ReleaseYear = 2017
            };

            // initialize book dictionary
            context.books.Add(book1.Isbn, book1);
            context.books.Add(book2.Isbn, book2);
            context.books.Add(book3.Isbn, book3);
            context.books.Add(book4.Isbn, book4);
            context.books.Add(book5.Isbn, book5);
            context.books.Add(book6.Isbn, book6);
            context.books.Add(book7.Isbn, book7);

            // create bookStates

            BookState bookState1 = new BookState
            {
                DateOfPurchase = new DateTimeOffset(2017, 5, 21, 00, 00, 00, new TimeSpan(1, 0, 0)),
                Book           = book1,
                Available      = true
            };

            BookState bookState2 = new BookState
            {
                DateOfPurchase = new DateTimeOffset(2017, 5, 21, 00, 00, 00, new TimeSpan(1, 0, 0)),
                Book           = book2,
                Available      = true
            };

            BookState bookState3 = new BookState
            {
                DateOfPurchase = new DateTimeOffset(2017, 5, 21, 00, 00, 00, new TimeSpan(1, 0, 0)),
                Book           = book3,
                Available      = true
            };

            BookState bookState4 = new BookState
            {
                DateOfPurchase = new DateTimeOffset(2017, 5, 21, 00, 00, 00, new TimeSpan(1, 0, 0)),
                Book           = book4,
                Available      = true
            };

            BookState bookState5 = new BookState
            {
                DateOfPurchase = new DateTimeOffset(2017, 5, 21, 00, 00, 00, new TimeSpan(1, 0, 0)),
                Book           = book5,
                Available      = true
            };

            BookState bookState6 = new BookState
            {
                DateOfPurchase = new DateTimeOffset(2017, 5, 21, 00, 00, 00, new TimeSpan(1, 0, 0)),
                Book           = book6,
                Available      = true
            };

            BookState bookState7 = new BookState
            {
                DateOfPurchase = new DateTimeOffset(2017, 5, 21, 00, 00, 00, new TimeSpan(1, 0, 0)),
                Book           = book7,
                Available      = true
            };

            // initialize bookStates List
            bookStates.Add(bookState1);
            bookStates.Add(bookState2);
            bookStates.Add(bookState3);
            bookStates.Add(bookState4);
            bookStates.Add(bookState5);
            bookStates.Add(bookState6);
            bookStates.Add(bookState7);

            //create events
            Event event1 = new Event()
            {
                BookState  = bookState1,
                BookReader = reader1,
                BorrowDate = new DateTimeOffset(2017, 05, 30, 12, 00, 00, new TimeSpan(1, 0, 0)),
                ReturnDate = new DateTimeOffset(2017, 06, 05, 12, 00, 00, new TimeSpan(1, 0, 0)),
            };

            Event event2 = new Event()
            {
                BookState  = bookState2,
                BookReader = reader2,
                BorrowDate = new DateTimeOffset(2017, 07, 10, 12, 00, 00, new TimeSpan(1, 0, 0)),
                ReturnDate = new DateTimeOffset(2017, 8, 05, 12, 00, 00, new TimeSpan(1, 0, 0)),
            };

            Event event3 = new Event()
            {
                BookState  = bookState1,
                BookReader = reader1,
                BorrowDate = new DateTimeOffset(2017, 9, 11, 12, 00, 00, new TimeSpan(1, 0, 0)),
                ReturnDate = new DateTimeOffset(2017, 9, 12, 12, 00, 00, new TimeSpan(1, 0, 0)),
            };

            Event event4 = new Event()
            {
                BookState  = bookState1,
                BookReader = reader1,
                BorrowDate = DateTimeOffset.Now
            };

            // initialize events collection
            events.Add(event1);
            events.Add(event2);
            events.Add(event3);
            events.Add(event4);
        }
Example #35
0
 public List <Book> GetBooksByState(BookState state)
 {
     return(GetAllBooks().Select(book => book).Where(book => book.State.Equals(state)).ToList());
 }
Example #36
0
 public override void TransitionTo(BookState transitionTo)
 {
     stateManager.CurrentState = transitionTo.Enter();
 }
Example #37
0
 public void AddStock(BookAmount amount)
 {
     this.Amount = new BookAmount(this.Amount.Amount + amount.Amount);
     this.State  = BookState.InStock;
 }
Example #38
0
 public void ChangeTheBookStateTo(BookState bookState)
 {
     this.activeBook.state = bookState;
 }
Example #39
0
 public BookStateTest()
 {
     this.Book      = new Book("tytuł", "autor", CoverType.HardcoverCaseWrap, "gatunek");
     this.BookState = new BookState(Book, 50, 30);
 }
Example #40
0
 /* Borrowing book */
 public void BorrowBook()
 {
     State = BookState.Borrowed;
 }
Example #41
0
 /* Returning book */
 public void ReturnBook()
 {
     State = BookState.Available;
 }
Example #42
0
 public void DeleteBookState(BookState bookState)
 {
     IDataRepository.DeleteBookState(bookState);
 }