public async Task Seed(WwwContext context, WwwCreate NewRun = null) { Random rng = new Random(); List <DateTime> dates = new List <DateTime>(); DateTime edate = DateTime.Today; for (int i = 0; i < 60; i++) { dates.Add(edate); edate.AddDays(-1); } for (int i = 0; i < 1000; i++) { EntityRunFormData data = new EntityRunFormData(); WwwWalk walk = context.wwwWalks.Include(i => i.WwwSchools).First(f => f.isActive == true); data.Walk = walk.Name; data.School = walk.WwwSchools.First().Name; int index = rng.Next(WwwData.s_classes.Length); data.SchoolClass = WwwData.s_classes[index]; data.Distance = (float)rng.Next(1, 41); data.Identifier = Guid.NewGuid().ToString("N"); index = rng.Next(dates.Count); data.Time = dates[index]; var ent = await Submit(context, data, true); } await context.SaveChangesAsync(); }
public async Task Create(WwwContext context, WwwCreate Create) { WwwWalk walk = new WwwWalk(); walk = new WwwWalk(); walk.isActive = true; walk.Name = Create.Name; walk.Start = DateTime.UtcNow; walk.TotalDistance = Create.TotalDistance; context.wwwWalks.Add(walk); WwwSchool school = new WwwSchool(); school.WwwWalk = walk; school.Name = Create.SchoolName; context.wwwSchools.Add(school); await context.SaveChangesAsync(); }