public static SessionCount GetSessionCount(DateTime date, ApplicationDbContext context = null) { var ContextInstance = context != null ? context : ApplicationDbContext.Create(); SessionCount count = ContextInstance.SessionCounts.FirstOrDefault(x => x.Date == date); return(count); }
public static int IncreaseTodayView(ApplicationDbContext context = null) { var ContextInstance = context != null ? context : ApplicationDbContext.Create(); SessionCount obj = GetTodaySesionCount(); obj.Count += 1; return(ContextInstance.SaveChanges()); }
public static SessionCount GetTodaySesionCount(ApplicationDbContext context = null) { var ContextInstance = context != null ? context : ApplicationDbContext.Create(); SessionCount todayCount = ContextInstance.SessionCounts.FirstOrDefault(x => x.Date == DateTime.Today); if (todayCount == null) { todayCount = new SessionCount { Date = DateTime.Today, Count = 0 }; ContextInstance.SessionCounts.Add(todayCount); ContextInstance.SaveChanges(); } return(todayCount); }
public override string ToString() { var builder = new System.Text.StringBuilder(); builder.AppendFormat("{0} {{", nameof(SessionInfo)).AppendLine(); builder.AppendFormat(" {0} = {1}", nameof(Version), Version.ToString()).AppendLine(); builder.AppendFormat(" {0} = {1}", nameof(MessageSessionIndex), MessageSessionIndex.ToString()).AppendLine(); builder.AppendFormat(" {0} = {1}", nameof(ServerSessionIndex), ServerSessionIndex.ToString()).AppendLine(); builder.AppendFormat(" {0} = {1}", nameof(SessionCount), SessionCount.ToString()).AppendLine(); builder.AppendFormat(" {0} = {1}", nameof(ServerName), ServerName.ToString()).AppendLine(); builder.AppendFormat(" {0} = {1}", nameof(TrackName), TrackName.ToString()).AppendLine(); builder.AppendFormat(" {0} = {1}", nameof(TrackLayout), TrackLayout.ToString()).AppendLine(); builder.AppendFormat(" {0} = {1}", nameof(SessionName), SessionName.ToString()).AppendLine(); builder.AppendFormat(" {0} = {1}", nameof(SessionType), SessionType.ToString()).AppendLine(); builder.AppendFormat(" {0} = {1}", nameof(SessionLengthLaps), SessionLengthLaps.ToString()).AppendLine(); builder.AppendFormat(" {0} = {1}", nameof(SessionLengthMinutes), SessionLengthMinutes.ToString()).AppendLine(); builder.AppendFormat(" {0} = {1}", nameof(WaitTime), WaitTime.ToString()).AppendLine(); builder.AppendFormat(" {0} = {1}", nameof(AmbientTemperature), AmbientTemperature.ToString()).AppendLine(); builder.AppendFormat(" {0} = {1}", nameof(RoadTemperature), RoadTemperature.ToString()).AppendLine(); builder.AppendFormat(" {0} = {1}", nameof(Weather), Weather.ToString()).AppendLine(); builder.AppendFormat(" {0} = {1}", nameof(Elapsed), Elapsed.ToString()).AppendLine(); builder.AppendFormat("}}").AppendLine(); return(builder.ToString()); }
public static int GetTodayViewCount() { SessionCount todayCount = GetTodaySesionCount(); return(todayCount.Count); }
public static IEnumerable <SessionCount> GetAllSessionCounts(this SaveFile saveFile, HeistDb heistDb) { return(saveFile.GetPlayedSessions().Select(x => SessionCount.FromDictKvp(x, heistDb)).Where(x => x.Heist.IsAvailable).ToList()); }
private static bool SeasonWasStarted(SessionCount x) { return(x.SessionState == SessionState.Started); }
private static bool SeasonWasCompleted(SessionCount x) { return(x.SessionState == SessionState.Completed); }