public async Task Handle(IEventWrapper <ICurveCalculated> wrapper, CancellationToken cancellationToken) { var @event = wrapper.Content; var asOfDate = @event.AsOfDate; var recipe = (await _recipeRepository.Single(x => x.Id == @event.CurveRecipeId)) ?? new RecipeDto { Id = @event.CurveRecipeId.NonEmpty(), Name = "unknown" }; var dto = await _dtoRepository.Single(x => x.AsOfDate == asOfDate); if (dto == null) { dto = new Dto { Id = NonEmpty.Guid(), AsOfDate = asOfDate, Recipes = new RecipeDto[] { recipe } }; await _dtoRepository.Insert(dto); } else { var recipes = dto.Recipes.ToList(); recipes.Add(recipe); dto.Recipes = recipes; await _dtoRepository.Update(dto); } }
public void UT_MarketCurve_AddCurvePoint_happy_flow() { var id = Guid.NewGuid(); var tenor = Tenor.FRA10x16; var instrument = new Instrument(NonEmpty.Guid(), Vendor.Bloomberg); var dateLag = new DateLag(-1); var priceType = PriceType.BIDPRICE; var isMandatory = false; Given(MarketCurveCreated(Country.GB, CurveType.ECB)) .When(c => c.AddCurvePoint(tenor, instrument, dateLag, priceType, isMandatory)) .Then(CurvePointAdded(tenor, instrument.Id, dateLag.Value, isMandatory, priceType)); }
public async Task Handle(IEventWrapper <ICurveCalculated> @event, CancellationToken cancellationToken) { var asOfDate = @event.Content.AsOfDate; var existingDto = await _readModelRepository.Single(x => x.AsOfDate == asOfDate); if (existingDto != null) { var dto = new Dto { Id = NonEmpty.Guid(), AsOfDate = asOfDate }; await _readModelRepository.Insert(dto); } }
public async Task Handle(IEventWrapper <ICurveCalculated> wrapper, CancellationToken cancellationToken) { var @event = wrapper.Content; var recipe = (CurveRecipe?)await _db.FindAsync <CurveRecipe>(@event.CurveRecipeId); _db.Add(new Dto { Id = wrapper.AggregateId, AsAtDate = wrapper.Timestamp.ToDateTimeUtc(), AsOfDate = @event.AsOfDate, CurveRecipeId = @event.CurveRecipeId.NonEmpty(), CurveRecipeName = recipe?.Name, Points = @event.Points.Select(p => new Point { Id = NonEmpty.Guid(), Currency = p.Currency, Maturity = p.Maturity, Value = p.Value }).ToImmutableArray() }); }