//PRIVATE METHODS private void checkBookCopyIsbn(BookExample bookExample) { if (!dataContext.Books.ContainsKey(bookExample.Book.Isbn)) { throw new Exception("Wrong book example Isbn reference"); } }
public void AddBookExample(BookExample bookExample) { if (dataContext.BookExamples.Contains(bookExample)) { throw new Exception("Data already exists"); } checkBookCopyIsbn(bookExample); dataContext.BookExamples.Add(bookExample); }
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))); } }
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"); } }
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); }
public Return(DateTime returnDate, Client client, BookExample bookExample, DateTime eventTime) : base(eventTime, client, bookExample) { ReturnDate = returnDate; }
public Purchase(Client client, BookExample bookExample, DateTime eventTime) : base(eventTime, client, bookExample) { }
protected Event(DateTime eventTime, Client client, BookExample bookExample) { EventTime = eventTime; Client = client; BookExample = bookExample; }