// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var config = new MongoDBConfig(); Configuration.Bind(config); #region Statistics var statisticsContext = new StatisticsContext(config); var statisticsRepository = new StatisticsRepository(statisticsContext); services.AddSingleton <StatisticsRepository>(statisticsRepository); #endregion var statistics = statisticsRepository.GetAll().GetAwaiter().GetResult(); if (statistics.Count() == 0) { this.seedDefaultStatisticsObject(statisticsRepository); } services.AddControllers(); services.AddCors(options => { options.AddPolicy(MyAllowSpecificOrigins, builder => { builder.WithOrigins("http://localhost:4200") .AllowAnyHeader() .AllowAnyMethod(); }); }); }
public async Task <ActionResult <Statistics> > Get() { var Statistics = await _statisticsRepository.GetAll(); return(new ObjectResult(Statistics.FirstOrDefault())); }
public IEnumerable <Statistics> GetAllStatistics() { return(statisticsRepository.GetAll()); }