public async Task <IActionResult> GetSettlementByTimePeriodAsJson([FromQuery] String timePeriod,
                                                                          [FromQuery] DateTime startDate,
                                                                          [FromQuery] DateTime endDate,
                                                                          CancellationToken cancellationToken)
        {
            String accessToken = await this.HttpContext.GetTokenAsync("access_token");

            if (timePeriod == "Day")
            {
                DataByDateModel model = await this.ApiClient.GetSettlementByDate(accessToken,
                                                                                 this.User.Identity as ClaimsIdentity,
                                                                                 startDate,
                                                                                 endDate,
                                                                                 cancellationToken);

                DataByDateViewModel viewModel = this.ViewModelFactory.ConvertFrom(model);
                return(this.Json(viewModel));
            }

            if (timePeriod == "Week")
            {
                DataByWeekModel model = await this.ApiClient.GetSettlementByWeek(accessToken,
                                                                                 this.User.Identity as ClaimsIdentity,
                                                                                 startDate,
                                                                                 endDate,
                                                                                 cancellationToken);

                DataByWeekViewModel viewModel = this.ViewModelFactory.ConvertFrom(model);
                return(this.Json(viewModel));
            }

            if (timePeriod == "Month")
            {
                DataByMonthModel model = await this.ApiClient.GetSettlementByMonth(accessToken,
                                                                                   this.User.Identity as ClaimsIdentity,
                                                                                   startDate,
                                                                                   endDate,
                                                                                   cancellationToken);

                DataByMonthViewModel viewModel = this.ViewModelFactory.ConvertFrom(model);
                return(this.Json(viewModel));
            }

            return(null);
        }
        /// <summary>
        /// Converts from.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public DataByDateViewModel ConvertFrom(DataByDateModel model)
        {
            if (model == null)
            {
                return(new DataByDateViewModel());
            }

            DataByDateViewModel viewModel = new DataByDateViewModel();

            viewModel.DataDateViewModels = new List <DataDateViewModel>();
            foreach (DataDateModel transactionDateModel in model.DataDateModels)
            {
                viewModel.DataDateViewModels.Add(new DataDateViewModel
                {
                    CurrencyCode = transactionDateModel.CurrencyCode,
                    Date         = transactionDateModel.Date,
                    Count        = transactionDateModel.Count,
                    Value        = transactionDateModel.Value
                });
            }

            return(viewModel);
        }