コード例 #1
0
        public async Task <IActionResult> SaveCovid(CovidClass covidClass)
        {
            await _covidService.SaveCovid(covidClass);

            IQueryable <CovidClass> covid = _covidService.GetList();

            return(Ok(covid));
        }
コード例 #2
0
        public async Task SaveCovid(CovidClass covid)
        {
            await _appDbContext.Covids.AddAsync(covid);

            await _appDbContext.SaveChangesAsync();

            await _context.Clients.All.SendAsync("ReceiveCovidList", GetCovidList());
        }
コード例 #3
0
        public IActionResult InitializeCovid()
        {
            Random rn = new Random();

            Enumerable.Range(1, 10).ToList().ForEach(i =>
            {
                foreach (ECity item in Enum.GetValues(typeof(ECity)))
                {
                    var newCovid = new CovidClass()
                    {
                        City      = item,
                        Count     = rn.Next(100, 10000),
                        CovidDate = DateTime.Now.AddDays(i)
                    };

                    _covidService.SaveCovid(newCovid).Wait();
                    System.Threading.Thread.Sleep(1000);
                }
            });

            return(Ok());
        }