public void Rent(Media media) { if (rentings.Count >= 3) { throw new BusinessRuleViolatedException(ErrorCode.MaximumOfMediaPermitedExceeded); } if (rentings.Any(x => x.DueDate < DateTime.Now)) { throw new BusinessRuleViolatedException(ErrorCode.CanNotRentWhenLateReturn); } if (rentings.Any(x => x.MediaId == media.EventSourceId)) { throw new BusinessRuleViolatedException(ErrorCode.AlreadyRented); } ApplyEvent(new CustomerRentedMediaEvent(media.EventSourceId, DateTime.Now.AddDays(7))); }