Example #1
0
 public void ChangeSreeningCriteria(InvestorId id, ScreeningCriteria screeningCriteria, Func <DateTimeOffset> getUtcNow)
 {
     Apply(new Events.V1.InvestorScreeningCriteriaChanged()
     {
         InvestorId        = id,
         ScreeningCriteria = screeningCriteria
     });
     MonitoredCompanies.ForEach(c => UpdateCompanyScore(c.CompanyId, getUtcNow));
 }
Example #2
0
 public void ChangeName(InvestorId id, string name, Func <DateTimeOffset> getUtcNow)
 {
     Apply(new Events.V1.InvestorNameChanged()
     {
         InvestorId = id,
         Name       = name,
         ChangedAt  = getUtcNow()
     });
 }
Example #3
0
 public void RegisterCompany(InvestorId id, CompanyId companyId, string name, List <ScreeningData> screeningData, Func <DateTimeOffset> getUtcNow)
 {
     Apply(new Events.V1.CompanyRegistered()
     {
         InvestorId    = id,
         CompanyId     = companyId,
         CompanyName   = name,
         ScreeningData = screeningData,
     });
     UpdateCompanyScore(companyId, getUtcNow);
 }
Example #4
0
        public void Register(InvestorId id, string name, Func <DateTimeOffset> getUtcNow)
        {
            if (Version >= 0)
            {
                throw new InvestorAlreadyRegistered();
            }
            if (id.Value == Guid.Empty)
            {
                id = new InvestorId(Guid.NewGuid());
            }

            Apply(new Events.V1.InvestorRegistered()
            {
                InvestorId        = id,
                Name              = name,
                RegisteredAt      = getUtcNow(),
                ScreeningCriteria = ScreeningCriteria.Default()
            });
        }
Example #5
0
        protected override void When(object e)
        {
            switch (e)
            {
            case Events.V1.InvestorRegistered x:
                Id   = new InvestorId(x.InvestorId);
                Name = x.Name;
                ScreeningCriteria = x.ScreeningCriteria;
                break;

            case Events.V1.InvestorNameChanged x:
                Name = x.Name;
                break;

            case Events.V1.InvestorScreeningCriteriaChanged x:
                //TODO: Improve to handle single changes
                ScreeningCriteria = x.ScreeningCriteria;
                break;

            case Events.V1.CompanyRegistered x:
                var company = new Company
                {
                    CompanyId     = x.CompanyId,
                    Name          = x.CompanyName,
                    ScreeningData = x.ScreeningData
                };
                MonitoredCompanies.Add(company);

                break;

            case Events.V1.CompanyScoreChanged x:
                var companyUpdated = MonitoredCompanies.FirstOrDefault(c => c.CompanyId == x.CompanyId);
                companyUpdated.ScreeningScore = new ScreeningScore(
                    x.Score,
                    x.MustHavesMissing,
                    x.NiceToHavePercentage,
                    x.SuperNiceToHavePercentage,
                    x.MissingKpis,
                    x.NoMetKpis);
                break;
            }
        }