예제 #1
0
        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);
        }
예제 #2
0
        public static int IncreaseTodayView(ApplicationDbContext context = null)
        {
            var          ContextInstance = context != null ? context : ApplicationDbContext.Create();
            SessionCount obj             = GetTodaySesionCount();

            obj.Count += 1;
            return(ContextInstance.SaveChanges());
        }
예제 #3
0
        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);
        }
예제 #4
0
        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());
        }
예제 #5
0
        public static int GetTodayViewCount()
        {
            SessionCount todayCount = GetTodaySesionCount();

            return(todayCount.Count);
        }
예제 #6
0
 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());
 }
예제 #7
0
 private static bool SeasonWasStarted(SessionCount x)
 {
     return(x.SessionState == SessionState.Started);
 }
예제 #8
0
 private static bool SeasonWasCompleted(SessionCount x)
 {
     return(x.SessionState == SessionState.Completed);
 }