public IEnumerable<IEvent> Register(int id, RegisterNewCustomerCommand cmd, CompanyIntelligenceReport report)
 {
     if (report.IsBankrupt)
         yield return new CustomerRegistrationWasRefused(cmd.RegistrationId, "Customer's company is bankrupt");
     var isPremium = IsPremiumCompany(report);
     yield return ApplyEvent(new NewCustomerWasRegistered(cmd.RegistrationId, id, isPremium, cmd.FirstName, cmd.LastName, cmd.Email, cmd.WorksForCompanyID));
 }
 public IEnumerable<IEvent> ChangeCompany(int newCompanyId, CompanyIntelligenceReport report)
 {
     EnsureIsRegistered("change company");
     var isPremiumCompany = IsPremiumCompany(report);
     if (!_isPremium && isPremiumCompany)
         yield return ApplyEvent(new CustomerWasAwardedPremiumStatus(_id));
     else 
     {
         if (_isPremium && !isPremiumCompany)
             yield return ApplyEvent(new CustomerPremiumStatusRevoked(_id, "Customer changed workplace to a non-premium company"));
         if (report.IsBankrupt)
             yield return ApplyEvent(new CustomerLostBuyingCapability(_id, "Customer changed workplace to a bankrupt company"));
     }
 }
 // ... handlers for other commands
 private bool IsPremiumCompany(CompanyIntelligenceReport report)
 {
     return(!report.IsBankrupt &&
            (report.AccumulatedSales > 1000000 || report.LastQuarterSales > 10000));
 }