public ActionResult Index() { ViewBag.Title = "My Statistics"; var ViewModel = new StatisticsViewModel() { Active = false }; var model = _statisticsRepository.Get(_usersRepository.GetCurrentUserId()); if (model != null) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <StatisticsFull, StatisticsViewModel>(); }); IMapper mapper = config.CreateMapper(); ViewModel = mapper.Map <StatisticsFull, StatisticsViewModel>(model); ViewModel.Active = true; } return(View(ViewModel)); }
public Statistics GetStatisticsById(long id) { return(statisticsRepository.Get(id)); }
public async Task <ActionResult <IEnumerable <Statistics> > > Get( Int32Parameter level, TimestampParameter timestamp, SelectParameter select, SortParameter sort, OffsetParameter offset, [Range(0, 10000)] int limit = 100, Symbols quote = Symbols.None) { #region validate if (sort != null && !sort.Validate("id", "level", "cycle", "date")) { return(new BadRequest($"{nameof(sort)}", "Sorting by the specified field is not allowed.")); } #endregion if (select == null) { return(Ok(await Statistics.Get(StatisticsPeriod.None, null, level, timestamp, null, sort, offset, limit, quote))); } if (select.Values != null) { if (select.Values.Length == 1) { return(Ok(await Statistics.Get(StatisticsPeriod.None, null, level, timestamp, null, sort, offset, limit, select.Values[0], quote))); } else { return(Ok(await Statistics.Get(StatisticsPeriod.None, null, level, timestamp, null, sort, offset, limit, select.Values, quote))); } } else { if (select.Fields.Length == 1) { return(Ok(await Statistics.Get(StatisticsPeriod.None, null, level, timestamp, null, sort, offset, limit, select.Fields[0], quote))); } else { return(Ok(new SelectionResponse { Cols = select.Fields, Rows = await Statistics.Get(StatisticsPeriod.None, null, level, timestamp, null, sort, offset, limit, select.Fields, quote) })); } } }