Esempio n. 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));
 }
Esempio n. 2
0
        public Task Handle <T>(T cmd) where T : class
        {
            switch (cmd)
            {
            case Contracts.Investors.V1.Register x:
                return(Execute(x.InvestorId, async inv =>
                {
                    inv.Register(x.InvestorId, x.Name, _getUtcNow);
                }));

            case Contracts.Investors.V1.ChangeName x:
                return(Execute(x.InvestorId, async inv =>
                {
                    inv.ChangeName(x.InvestorId, x.Name, _getUtcNow);
                }));

            case Contracts.Investors.V1.ChangeScreeningCriteria x:
                return(Execute(x.InvestorId, async inv =>
                {
                    var sc = new ScreeningCriteria
                    {
                        MustHave = x.MustHave.Select(c => Enum.Parse <KPI>(c))?.ToList(),
                        NiceToHave = x.NiceToHave.Select(c => Enum.Parse <KPI>(c))?.ToList(),
                        SuperNiceToHave = x.SuperNiceToHave.Select(c => Enum.Parse <KPI>(c))?.ToList()
                    };
                    inv.ChangeSreeningCriteria(x.InvestorId, sc, _getUtcNow);
                }));

            case Contracts.Investors.V1.RegisterCompany x:
                return(Execute(x.InvestorId, async inv =>
                {
                    var name = x.CompanyName;
                    var screeningData = x.ScreeningData.Select(d => new ScreeningData
                    {
                        Status = d.Status,
                        Kpi = (KPI)d.KPI
                    }).ToList();
                    inv.RegisterCompany(x.InvestorId, x.CompanyId, name, screeningData, _getUtcNow);
                }));


            default:
                return(Task.CompletedTask);
            }
        }
Esempio n. 3
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()
            });
        }
Esempio n. 4
0
 public ScoreCalculator(ScreeningCriteria screeningCriteria)
 {
     _screeningCriteria = screeningCriteria;
 }