public static async Task AddPeriodsAsync(IEnumerable <Period> periods) { using (var context = new PeriodContext()) { context.Periods.AddRange(periods); await context.SaveChangesAsync(); } }
public static async Task AddPeriodAsync(bool isInPomodoro, bool hasFinished, DateTime startTime, DateTime endTime) { using (var context = new PeriodContext()) { context.Periods.Add(new Period { From = startTime, HasFinished = hasFinished, To = endTime, IsFocus = isInPomodoro }); await context.SaveChangesAsync(); } }
public static async Task RemoveFuturePeriodsAsync() { using (var context = new PeriodContext()) { var time = DateTime.Now; var periods = await context.Periods.Where(p => p.From > time).ToListAsync(); context.Periods.RemoveRange(periods); int records = await context.SaveChangesAsync(); } }