private static bool ReaderCompare(Reader a, Reader b) { if (Object.ReferenceEquals(a, b)) { return true; } return a.Id == b.Id && a.FullName == b.FullName && a.Address == b.Address; }
public bool AuthorizationReader(Reader reader) { if (activeReaders.Contains(reader)) { return false; } else { activeReaders.Add(reader); return true; } }
public LibraryClassTest() { repository = new Repository(new MSSQLRepositoryFactory()); reader = new Reader("First Reader", "Brest"); repository.ReaderRepository.Save(reader); department = new LibraryDepartment("Abonement", true); repository.LibraryDepartmentRepository.Save(department); librarian = new Librarian("First Librarian ", department); repository.LibrarianRepository.Save(librarian); book = new Book("First Author", "Title", 2002, department); repository.BookRepository.Save(book); book2 = new Book("Second Author", "Title", 2000, department); repository.BookRepository.Save(book2); library = new LibraryClass(repository); }
partial void DeleteReader(Reader instance);
partial void UpdateReader(Reader instance);
partial void InsertReader(Reader instance);
public void Order_If_Book_Already_Ordered_Test() { var listBooks = new List<Book>(); var book = new Book(Guid.Empty, "Name", "Title", 2000, new LibraryDepartment()); listBooks.Add(book); library.Setup(lib => lib.GetAllBooks()).Returns(listBooks); var reader = new Reader("Name", "Address"); library.Setup(lib => lib.GetReader(It.IsAny<string>())).Returns(reader); library.Setup(lib => lib.OrderBook(book, reader)).Returns(false); libraryController.ControllerContext = new ControllerContext() { Controller = libraryController, RequestContext = new RequestContext(new MockHttpContext(), new RouteData()) }; var result = libraryController.Order(Guid.Empty) as ViewResult; Assert.IsNotNull(result); Assert.AreEqual("Книга уже была выдана.", result.ViewData["Message"]); }
public ReaderTest() { r1 = new Reader("Name1", "Address1"); r2 = new Reader("Name2", "Address2"); r3 = new Reader(r1.Id, "Name1", "Address1"); }
public bool OrderBook(Book book, Reader reader) { if (openOrders.Select(o => o.Book).Contains(book)) return false; if (!activeReaders.Contains(reader)) return false; Order order = new Order(reader, book); order.TimeGetBook = DateTime.Now; order.TimeReturnBook = DateTime.Now; order.LibrarianOpenOrder = workLibrarians.First(l => l.Department == book.Department); openOrders.Add(order); repository.OrderRepository.Save(order); return true; }
public IEnumerable<Book> GetBooksOrderedByReader(Reader reader) { return openOrders.Where(order => order.Reader == reader).Select(order => order.Book); }
public bool ExitReader(Reader reader) { activeReaders.Remove(reader); return true; }
public Reader AddReader(string fullName, string address) { Reader reader = new Reader(fullName, address); repository.ReaderRepository.Save(reader); return reader; }
public override IEnumerable<Order> GetOrdersByReader(Reader reader, bool closed) { return context.Orders.Where(order => order.Reader.Id == reader.Id && order.Closed == closed); }