public void AddLending(LibraryItem item, User user, DateTime lendingDate) { var lendingDetails = new LendingDetails(item, user, lendingDate); this.lendings.Add(lendingDetails); user.AddLending(lendingDetails); }
public void Register(LibraryItem item) { var checkitem = this.store.GetItem(item.ID); if (checkitem != null) { throw new ArgumentException( String.Format("El elemento con el ID {0} ya existe en el catálogo.", item.ID) , "item"); } this.store.AddItem(item); }
public LendingDetails(LibraryItem item, User user, DateTime lendingDate) { this.User = user; this.Item = item; this.LendingDate = lendingDate; }
public void AddItem(Entities.LibraryItem item) { this.catalog.Add(item); }
public void RemoveLending(LibraryItem item, User user, DateTime returnDate) { var lending = lendings.Where(i => i.Item.ID == item.ID).Single(); this.lendings.Remove(lending); user.RemoveLending(lending); }
public bool IsAvailableForLending(LibraryItem item, DateTime lendingDate) { var alreadyExistingLending = this.lendings.Where(x => x.Item.ID == item.ID).FirstOrDefault(); return alreadyExistingLending == null; }
private bool UserHasExceededLendingLength(LibraryItem item, User user, DateTime date) { bool result = false; var lending = user.Lendings.Where(l => l.Item.ID == item.ID).Single(); var elapsedDays = (date - lending.LendingDate).Days; if (elapsedDays > item.DaysToLend()) { result = true; } return result; }
private bool UserHasOutstandingLending(LibraryItem item, User user) { bool result = false; if (user.Lendings.Count() == 0) { return false; } if (user.Lendings.Any(x => x.Item.ID == item.ID)) { result = true; } return result; }
private bool UserCanCurrentlyLendItem(LibraryItem item, User user) { bool result = false; if (user.Status == UserStatus.Blocked) { return result; } if (user.Lendings.Count(l => l.Item.GetType() == item.GetType()) < item.MaximumNumberOfItemsInLending()) { result = true; } return result; }