Exemplo n.º 1
0
 public static FUTMuleApiStatistic GetInstance()
 {
     lock (_statisticLock)
     {
         using (var ctx = new FUTLogsDatabase())
         {
             var statistic = ctx.FUTMuleApiStatistics.FirstOrDefault();
             if (statistic == null)
             {
                 var ret = new FUTMuleApiStatistic();
                 ret.Reset();
                 ctx.FUTMuleApiStatistics.Add(ret);
                 ctx.SaveChanges();
                 return(ret);
             }
             return(statistic);
         }
     }
 }
Exemplo n.º 2
0
 public void SaveChanges()
 {
     lock (_statisticLock)
     {
         using (var context = new FUTLogsDatabase())
         {
             var statistic = context.FUTMuleApiStatistics.FirstOrDefault();
             if (statistic == null)
             {
                 statistic = new FUTMuleApiStatistic();
                 statistic.Reset();
                 context.FUTMuleApiStatistics.Add(statistic);
                 context.SaveChanges();
             }
             else
             {
                 context.Entry(statistic).CurrentValues.SetValues(this);
                 context.SaveChanges();
             }
         }
     }
 }