private void CreateUserActivityForGame(IGame game, Random random, List <UserActivity> userActivities) { var earliestDateOrToday = userActivities.Select(x => x.AssignedToDate).DefaultIfEmpty(DateTimeOffset.Now.Date).Min(); var totalSessionsToCreate = random.Next(10, 20); for (var sessionNumber = 0; sessionNumber < totalSessionsToCreate; sessionNumber++) { earliestDateOrToday = earliestDateOrToday.AddDays(random.Next(1, 2) * -1); var startTime = earliestDateOrToday.AddSeconds(random.Next(StartTimeOfDayInSeconds, EndTimeOfDayInSeconds)); var endTime = startTime.AddSeconds(random.Next(MinimumLengthOfSessions, MaximumLengthOfSessions)); var userActivity = new UserActivity { UserActivityId = Id <UserActivity> .NewId(), ProcessSessionId = Id <ProcessSession> .NewId(), StartTime = startTime, EndTime = endTime, AssignedToDate = AssignDateRangeToDateStrategy.DetermineAssignedDate(startTime, endTime), GameId = game.GameId, }; userActivities.Add(userActivity); } }
public UserActivity Create(ProcessSession processSession, IGame game) { return(new UserActivity { UserActivityId = Guid.Id <UserActivity> .NewId(), GameId = game.GameId, AssignedToDate = AssignDateRangeToDateStrategy.DetermineAssignedDate(processSession.StartTime, processSession.EndTime), StartTime = processSession.StartTime, EndTime = processSession.EndTime, ProcessSessionId = processSession.ProcessSessionId, }); }