Update_8_34.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using Comal.Classes;
  2. using InABox.Core;
  3. using InABox.Database;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace PRS.Shared.Database_Update_Scripts;
  10. internal class Update_8_34 : DatabaseUpdateScript
  11. {
  12. public override VersionNumber Version => new(8, 34);
  13. private static void DoEventNotificationsEnabled()
  14. {
  15. var provider = DbFactory.NewProvider(Logger.Main);
  16. Logger.Send(LogType.Information, "", $"Initialising Event.NotificationsEnabled to true...");
  17. var events = provider.Query(
  18. null,
  19. Columns.None<Event>().Add(x => x.ID).Add(x => x.NotificationsEnabled))
  20. .ToArray<Event>();
  21. foreach(var ev in events)
  22. {
  23. ev.NotificationsEnabled = true;
  24. }
  25. provider.Save(events);
  26. Logger.Send(LogType.Information, "", $"Initialised Event.NotificationsEnabled to true");
  27. }
  28. public override bool Update()
  29. {
  30. DoEventNotificationsEnabled();
  31. return true;
  32. }
  33. }