Esempio n. 1
0
        public static void Save(VolleyballClub manager)
        {
            var    jss  = new JavaScriptSerializer();
            String data = jss.Serialize(manager);

            File.WriteAllText(System.AppDomain.CurrentDomain.BaseDirectory + Constants.DATAFILE + DateTime.Today.ToString("yyyy-MM-dd"), data);
        }
Esempio n. 2
0
 public static VolleyballClub LoadReservation()
 {
     for (int i = 0; i < 90; i++)
     {
         String dataFilePath = System.AppDomain.CurrentDomain.BaseDirectory + Constants.DATAFILE + DateTime.Today.AddDays(-1 * i).ToString("yyyy-MM-dd");
         if (File.Exists(dataFilePath))
         {
             lock (dbLock)
             {
                 var            jss     = new JavaScriptSerializer();
                 String         data    = File.ReadAllText(dataFilePath);
                 VolleyballClub manager = jss.Deserialize <VolleyballClub>(data);
                 //
                 foreach (Pool pool in manager.Pools)
                 {
                     if (pool.Id == null)
                     {
                         pool.Id = Guid.NewGuid().ToString();
                         Save(manager);
                     }
                 }
                 return(manager);
             }
         }
     }
     return(new VolleyballClub());
 }
Esempio n. 3
0
        public static bool IsDropinSpotOpening(DateTime date, Pool pool, VolleyballClub manager)
        {
            DateTime reserveDate = TimeZoneInfo.ConvertTimeFromUtc(date, TimeZoneInfo.FindSystemTimeZoneById(manager.TimeZoneName));

            reserveDate = reserveDate.AddDays(-1 * pool.DaysBeforeReserve).AddHours(-1 * reserveDate.Hour + manager.DropinSpotOpeningHour);
            DateTime now = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById(manager.TimeZoneName));

            return(now >= reserveDate);
        }
Esempio n. 4
0
        public static bool IsReservationLocked(DateTime date, VolleyballClub manager)
        {
            DateTime lockDate = TimeZoneInfo.ConvertTimeFromUtc(date, TimeZoneInfo.FindSystemTimeZoneById(manager.TimeZoneName));

            lockDate = lockDate.AddHours(-1 * lockDate.Hour + manager.LockReservationHour);
            DateTime now = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById(manager.TimeZoneName));

            return(now >= lockDate);
        }