Esempio n. 1
0
        private bool CheckTimeInterval(BBQReserverBot.Model.Record record)
        {
            var interseptions = from r in Schedule.Records
                                where r.FromTime <record.ToTime && r.ToTime> record.FromTime
                                select r;

            return(interseptions.Count() > 0);
        }
Esempio n. 2
0
 public bool Create(Telegram.Bot.Types.User user)
 {
     BBQReserverBot.Model.Record r = new BBQReserverBot.Model.Record();
     r.Id       = Guid.NewGuid();
     r.User     = user;
     r.FromTime = new DateTime(DateTime.Now.Year, SelectedMonth, SelectedDay, SelectedStart, 0, 0);
     r.ToTime   = new DateTime(DateTime.Now.Year, SelectedMonth, SelectedDay, SelectedEnd, 0, 0);
     if (r.FromTime < r.ToTime)
     {
         r.ToTime.AddDays(1);
     }
     if (r.FromTime < DateTime.Now)
     {
         r.FromTime.AddYears(1);
         r.ToTime.AddYears(1);
     }
     if (CheckTimeInterval(r))
     {
         return(false);
     }
     Schedule.Records.Add(r);
     return(true);
 }