public void AddRent(Rent rent) { if (Rents == null) { Rents = new List <Rent>(); } Rents.Add(rent); }
public void AddRents(List <Rent> rents) { if (Rents == null) { Rents = new List <Rent>(); } foreach (Rent r in rents) { Rents.Add(r); } }
public void Delete_HasRents_ShouldThrowInvalidCountException() { var first = Invoices.First(); var incomingBook = first.IncomingBooks.First(); Rents.Add(new Rent(incomingBook.Book, Subscribers.First(), Books.Single(x => x.Id == incomingBook.Book.Id).Count) { Id = _random.Next(int.MaxValue) }); Assert.Throws <InvoiceCountException>(async() => await InvoicesService.Delete(first.Id)); }
public void QueryRent() { if (null == CurrentPerson) { Status = string.Format("请选择会员,再查询相应的借阅记录"); return; } var rents = _repo.Query(e => e.Person == CurrentPerson && e.EndDate == DateTime.MinValue); Rents.Clear(); foreach (var item in rents) { Rents.Add(item); } _rentCount = rents.Sum(e => e.Count); Status = string.Format("{0}: 未归还{1}本", CurrentPerson.Name, _rentCount); }
public void Create_BookNotHasAvailableCount_ShouldThrownBookNotHasAvailableCountException() { var book = Books.First(); var reserved = Rents.Where(x => x.Book.Id == book.Id).Sum(x => x.Count); Rents.Add(new Rent(book, Subscribers.First(), book.Count - reserved) { Id = Random.Next(int.MaxValue), Date = DateTime.Now, }); var dto = new RentDto() { Subscriber = Mapper.Map <SubscriberDto>(Subscribers.First()), Book = Mapper.Map <BookDto>(book), Count = 1, Date = DateTime.Now, }; Assert.Throws <NotHasAvailableBooksCountException>(async() => await RentsService.Create(dto)); }