コード例 #1
0
        public void GetDataForecastPessimisticTest()
        {
            IForecastModel forecastModel = new ForecastModel(_data, 12, 12, Scheme.Period.Month);

            var data = forecastModel.GetData().GetOnlyForecastPessimistic(3).Sum(_ => _.Value);

            data.Should().Be(277737);
        }
コード例 #2
0
        public void GetDataHistoricTest()
        {
            IForecastModel forecastModel = new ForecastModel(_data, 12, 12, Scheme.Period.Month);

            var data = forecastModel.GetData().GetOnlyHistoric(3).Sum(_ => _.Value);

            data.Should().Be(292594);
        }
コード例 #3
0
        //[SwaggerResponseExample(HttpStatusCode.OK, typeof(DashboardDataExample))]
        public async Task <IHttpActionResult> GetByReportId(string id)
        {
            try
            {
                var dashboardDtos = await _Dashboardservice.GetByReportIdAsync(id);

                if (!dashboardDtos.Any())
                {
                    return(NotFound());
                }
                var Dashboardshorts = _mapper.Map <IEnumerable <DashboardData> >(dashboardDtos);

                var dataTempDtos = await _Dashboardservice.GetAnalyticDataAsync();

                var dataDtos = dataTempDtos.ToArray().OrderBy(_ => _.Date).ToArray();
                foreach (var item in dataDtos)
                {
                    item.Value = item.KursDollarValue;
                }
                var dataForecastData = _mapper.Map <IEnumerable <Data> >(dataDtos);

                IForecastModel forecastModel = new ForecastModel(dataForecastData, 12, 40, Scheme.Period.Day);

                var dashboard = Dashboardshorts.FirstOrDefault();

                var data = forecastModel.GetData().ToArray();
                //var dataCount = dat.Length - 15;
                //var data = dat.Skip(dataCount);
                var dataForecast = data.GetOnlyForecastPessimistic(40).ToArray();
                //var dataCount = dat.Length - 15;
                //var data = dat.Skip(dataCount);

                dashboard.Dates  = dataForecast.Select(_ => _.Date.ToString("d"));
                dashboard.Values = dataForecast.Select(_ => _.Value);

                DashboardData[] dashboardDatas = new[] { dashboard };

                return(Ok(dashboardDatas));
            }
            catch (InvalidOperationException ioe)
            {
                return(InternalServerError(ioe));
            }
        }