// GET: Dashboard public IActionResult Index() { var model = new DashboardViewModel(); var statistics = _queryDispatcher.Execute(new StatisticsByTimeSliceQuery(_timeSliceCreationService.CreateTimeSlices(), TimeSliceType.All)); model.Cards = _statisticCardConverterRepository.ConvertStatistic(statistics.FirstOrDefault(s => s.TimeSlice.Type.Equals(TimeSliceType.All))); model.OpenPositions = Mapper.Map <OpenPositionsViewModel>(_transactionCalculationService.CalculateOpenPositions()); return(View(model)); }
/// <summary> /// Processes the given event <paramref name="eventData"/> /// </summary> /// <param name="eventData">Event data</param> public void Handle(StaticsticsBasicDataChangedEvent eventData) { var slices = _timeSliceCreationService.CreateTimeSlices(eventData.Date); //Re-calculate the statistics for all slices in parallel, because they to not overlap. The items in the repository //are therefore accessed in a non-blocking way. Parallel.ForEach(slices.GetAllSlices(), slice => { using (new TimeMeasure(ms => _loggingService.Debug($"Re-Calculate statistics for time range: {slice} in {ms} msec"))) { var calculationResult = _statisticService.Calculate(slice); if (calculationResult == null) { return; } var item = _modelRepository.GetById(calculationResult); if (item != null) { _modelRepository.Update(calculationResult); } else { _modelRepository.Add(calculationResult); } } }); }
// GET: Dashboard public ActionResult Index() { var model = new DashboardViewModel(); var statistic = _queryDispatcher.Execute(new StatisticsByTimeSliceQuery(_timeSliceCreationService.CreateTimeSlices())); model.Cards = _statisticCardConverterRepository.ConvertStatistic(statistic); //NOTE: Cache disabled because of IQuotation overrides Equals and only date is taken into account model.OpenPositions = Mapper.Map <OpenPositionsViewModel>(_transactionCalculationService.CalculateOpenPositions(), o => o.DisableCache = true); return(View(model)); }