Beispiel #1
0
        //PRIVATE METHODS

        private void checkBookCopyIsbn(BookExample bookExample)
        {
            if (!dataContext.Books.ContainsKey(bookExample.Book.Isbn))
            {
                throw new Exception("Wrong book example Isbn reference");
            }
        }
Beispiel #2
0
 public void AddBookExample(BookExample bookExample)
 {
     if (dataContext.BookExamples.Contains(bookExample))
     {
         throw new Exception("Data already exists");
     }
     checkBookCopyIsbn(bookExample);
     dataContext.BookExamples.Add(bookExample);
 }
Beispiel #3
0
 public override bool Equals(object obj)
 {
     if ((obj == null) || !this.GetType().Equals(obj.GetType()))
     {
         return(false);
     }
     else
     {
         BookExample other = (BookExample)obj;
         return((this.Book.Equals(other.Book)) && (this.Tax.Equals(other.Tax)) && (this.BasePrice.Equals(other.BasePrice)));
     }
 }
Beispiel #4
0
        public void DeleteBookExample(BookExample bookExample)
        {
            foreach (Event evnt in dataContext.Events)
            {
                if (evnt.BookExample == bookExample)
                {
                    throw new Exception("Book example is in use, can't be deleted");
                }
            }
            Boolean result = dataContext.BookExamples.Remove(bookExample);

            if (!result)
            {
                throw new Exception("No such book copy");
            }
        }
Beispiel #5
0
        public void UpdateBookExample(int Id, BookExample bookExample)
        {
            if (!(Id < dataContext.BookExamples.Count))
            {
                throw new Exception("No such book copy index");
            }
            if (dataContext.BookExamples.Contains(bookExample))
            {
                throw new Exception("Data already exists");
            }
            checkBookCopyIsbn(bookExample);
            BookExample currentBookExample = GetBookExample(Id);

            foreach (Event evnt in dataContext.Events)
            {
                if (evnt.BookExample == currentBookExample)
                {
                    evnt.BookExample = bookExample;
                }
            }
            dataContext.BookExamples.Remove(currentBookExample);
            dataContext.BookExamples.Insert(Id, bookExample);
        }
Beispiel #6
0
 public Return(DateTime returnDate, Client client, BookExample bookExample, DateTime eventTime) : base(eventTime, client, bookExample)
 {
     ReturnDate = returnDate;
 }
Beispiel #7
0
 public Purchase(Client client, BookExample bookExample, DateTime eventTime) : base(eventTime, client, bookExample)
 {
 }
Beispiel #8
0
 protected Event(DateTime eventTime, Client client, BookExample bookExample)
 {
     EventTime   = eventTime;
     Client      = client;
     BookExample = bookExample;
 }