diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json
new file mode 100644
index 0000000..429547e
--- /dev/null
+++ b/.config/dotnet-tools.json
@@ -0,0 +1,12 @@
+{
+ "version": 1,
+ "isRoot": true,
+ "tools": {
+ "fake-cli": {
+ "version": "5.23.0",
+ "commands": [
+ "fake"
+ ]
+ }
+ }
+}
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 72d666f..09c26fe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -332,5 +332,6 @@ ASALocalRun/
### --- ###
src/PrayerTracker/appsettings.json
docs/_site
+**/*.db*
.ionide
\ No newline at end of file
diff --git a/build.fsx b/build.fsx
new file mode 100644
index 0000000..50b9aa1
--- /dev/null
+++ b/build.fsx
@@ -0,0 +1,44 @@
+#r "paket:
+nuget Fake.DotNet.Cli
+nuget Fake.DotNet.Testing.Expecto
+nuget Fake.IO.FileSystem
+nuget Fake.Core.Target //"
+#load ".fake/build.fsx/intellisense.fsx"
+open Fake.Core
+open Fake.DotNet
+open Fake.DotNet.Testing
+open Fake.IO
+open Fake.IO.Globbing.Operators
+open Fake.Core.TargetOperators
+
+Target.initEnvironment ()
+
+/// The root path to the projects within this solution
+let projPath = "src/PrayerTracker"
+
+Target.create "Clean" (fun _ ->
+ !! "src/**/bin"
+ ++ "src/**/obj"
+ |> Shell.cleanDirs
+)
+
+Target.create "Test" (fun _ ->
+ let testPath = $"{projPath}.Tests"
+ DotNet.build (fun opts -> { opts with NoLogo = true }) $"{testPath}/PrayerTracker.Tests.fsproj"
+ Expecto.run
+ (fun opts -> { opts with WorkingDirectory = $"{testPath}/bin/Release/net6.0" })
+ [ "PrayerTracker.Tests.dll" ])
+
+Target.create "Publish" (fun _ ->
+ DotNet.publish
+ (fun opts -> { opts with Runtime = Some "linux-x64"; SelfContained = Some false; NoLogo = true })
+ $"{projPath}/PrayerTracker.fsproj")
+
+Target.create "All" ignore
+
+"Clean"
+ ==> "Test"
+ ==> "Publish"
+ ==> "All"
+
+Target.runOrDefault "All"
diff --git a/build.fsx.lock b/build.fsx.lock
new file mode 100644
index 0000000..1d92727
--- /dev/null
+++ b/build.fsx.lock
@@ -0,0 +1,233 @@
+STORAGE: NONE
+RESTRICTION: || (== net6.0) (== netstandard2.0)
+NUGET
+ remote: https://api.nuget.org/v3/index.json
+ BlackFox.VsWhere (1.1)
+ FSharp.Core (>= 4.2.3)
+ Microsoft.Win32.Registry (>= 4.7)
+ Fake.Core.CommandLineParsing (5.23)
+ FParsec (>= 1.1.1)
+ FSharp.Core (>= 6.0)
+ Fake.Core.Context (5.23)
+ FSharp.Core (>= 6.0)
+ Fake.Core.Environment (5.23)
+ FSharp.Core (>= 6.0)
+ Fake.Core.FakeVar (5.23)
+ Fake.Core.Context (>= 5.23)
+ FSharp.Core (>= 6.0)
+ Fake.Core.Process (5.23)
+ Fake.Core.Environment (>= 5.23)
+ Fake.Core.FakeVar (>= 5.23)
+ Fake.Core.String (>= 5.23)
+ Fake.Core.Trace (>= 5.23)
+ Fake.IO.FileSystem (>= 5.23)
+ FSharp.Core (>= 6.0)
+ System.Collections.Immutable (>= 5.0)
+ Fake.Core.SemVer (5.23)
+ FSharp.Core (>= 6.0)
+ Fake.Core.String (5.23)
+ FSharp.Core (>= 6.0)
+ Fake.Core.Target (5.23)
+ Fake.Core.CommandLineParsing (>= 5.23)
+ Fake.Core.Context (>= 5.23)
+ Fake.Core.Environment (>= 5.23)
+ Fake.Core.FakeVar (>= 5.23)
+ Fake.Core.Process (>= 5.23)
+ Fake.Core.String (>= 5.23)
+ Fake.Core.Trace (>= 5.23)
+ FSharp.Control.Reactive (>= 5.0.2)
+ FSharp.Core (>= 6.0)
+ Fake.Core.Tasks (5.23)
+ Fake.Core.Trace (>= 5.23)
+ FSharp.Core (>= 6.0)
+ Fake.Core.Trace (5.23)
+ Fake.Core.Environment (>= 5.23)
+ Fake.Core.FakeVar (>= 5.23)
+ FSharp.Core (>= 6.0)
+ Fake.Core.Xml (5.23)
+ Fake.Core.String (>= 5.23)
+ FSharp.Core (>= 6.0)
+ Fake.DotNet.Cli (5.23)
+ Fake.Core.Environment (>= 5.23)
+ Fake.Core.Process (>= 5.23)
+ Fake.Core.String (>= 5.23)
+ Fake.Core.Trace (>= 5.23)
+ Fake.DotNet.MSBuild (>= 5.23)
+ Fake.DotNet.NuGet (>= 5.23)
+ Fake.IO.FileSystem (>= 5.23)
+ FSharp.Core (>= 6.0)
+ Mono.Posix.NETStandard (>= 1.0)
+ Newtonsoft.Json (>= 13.0.1)
+ Fake.DotNet.MSBuild (5.23)
+ BlackFox.VsWhere (>= 1.1)
+ Fake.Core.Environment (>= 5.23)
+ Fake.Core.Process (>= 5.23)
+ Fake.Core.String (>= 5.23)
+ Fake.Core.Trace (>= 5.23)
+ Fake.IO.FileSystem (>= 5.23)
+ FSharp.Core (>= 6.0)
+ MSBuild.StructuredLogger (>= 2.1.545)
+ Fake.DotNet.NuGet (5.23)
+ Fake.Core.Environment (>= 5.23)
+ Fake.Core.Process (>= 5.23)
+ Fake.Core.SemVer (>= 5.23)
+ Fake.Core.String (>= 5.23)
+ Fake.Core.Tasks (>= 5.23)
+ Fake.Core.Trace (>= 5.23)
+ Fake.Core.Xml (>= 5.23)
+ Fake.IO.FileSystem (>= 5.23)
+ Fake.Net.Http (>= 5.23)
+ FSharp.Core (>= 6.0)
+ Newtonsoft.Json (>= 13.0.1)
+ NuGet.Protocol (>= 5.11)
+ Fake.DotNet.Testing.Expecto (5.23)
+ Fake.Core.Process (>= 5.23)
+ Fake.Core.String (>= 5.23)
+ Fake.Core.Trace (>= 5.23)
+ Fake.IO.FileSystem (>= 5.23)
+ Fake.Testing.Common (>= 5.23)
+ FSharp.Core (>= 6.0)
+ Fake.IO.FileSystem (5.23)
+ Fake.Core.String (>= 5.23)
+ FSharp.Core (>= 6.0)
+ Fake.Net.Http (5.23)
+ Fake.Core.Trace (>= 5.23)
+ FSharp.Core (>= 6.0)
+ Fake.Testing.Common (5.23)
+ Fake.Core.Trace (>= 5.23)
+ FSharp.Core (>= 6.0)
+ FParsec (1.1.1)
+ FSharp.Core (>= 4.3.4)
+ FSharp.Control.Reactive (5.0.5)
+ FSharp.Core (>= 4.7.2)
+ System.Reactive (>= 5.0 < 6.0)
+ FSharp.Core (6.0.5)
+ Microsoft.Build (17.2)
+ Microsoft.Build.Framework (>= 17.2) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net472)) (&& (== netstandard2.0) (>= net6.0))
+ Microsoft.NET.StringTools (>= 1.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net472)) (&& (== netstandard2.0) (>= net6.0))
+ Microsoft.Win32.Registry (>= 4.3) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0))
+ System.Collections.Immutable (>= 5.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net472)) (&& (== netstandard2.0) (>= net6.0))
+ System.Configuration.ConfigurationManager (>= 4.7) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net472)) (&& (== netstandard2.0) (>= net6.0))
+ System.Reflection.Metadata (>= 1.6) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0))
+ System.Security.Principal.Windows (>= 4.7) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0))
+ System.Text.Encoding.CodePages (>= 4.0.1) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0))
+ System.Text.Json (>= 6.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net472)) (&& (== netstandard2.0) (>= net6.0))
+ System.Threading.Tasks.Dataflow (>= 6.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net472)) (&& (== netstandard2.0) (>= net6.0))
+ Microsoft.Build.Framework (17.2)
+ Microsoft.Win32.Registry (>= 4.3)
+ System.Security.Permissions (>= 4.7)
+ Microsoft.Build.Tasks.Core (17.2)
+ Microsoft.Build.Framework (>= 17.2)
+ Microsoft.Build.Utilities.Core (>= 17.2)
+ Microsoft.NET.StringTools (>= 1.0)
+ Microsoft.Win32.Registry (>= 4.3)
+ System.CodeDom (>= 4.4)
+ System.Collections.Immutable (>= 5.0)
+ System.Reflection.Metadata (>= 1.6)
+ System.Resources.Extensions (>= 4.6)
+ System.Security.Cryptography.Pkcs (>= 4.7)
+ System.Security.Cryptography.Xml (>= 4.7)
+ System.Security.Permissions (>= 4.7)
+ System.Threading.Tasks.Dataflow (>= 6.0)
+ Microsoft.Build.Utilities.Core (17.2)
+ Microsoft.Build.Framework (>= 17.2)
+ Microsoft.NET.StringTools (>= 1.0)
+ Microsoft.Win32.Registry (>= 4.3)
+ System.Collections.Immutable (>= 5.0)
+ System.Configuration.ConfigurationManager (>= 4.7)
+ System.Security.Permissions (>= 4.7) - restriction: == netstandard2.0
+ System.Text.Encoding.CodePages (>= 4.0.1) - restriction: == netstandard2.0
+ Microsoft.NET.StringTools (1.0)
+ System.Memory (>= 4.5.4)
+ System.Runtime.CompilerServices.Unsafe (>= 5.0)
+ Microsoft.NETCore.Platforms (6.0.5) - restriction: || (&& (== net6.0) (< netcoreapp3.1)) (&& (== net6.0) (< netstandard1.2)) (&& (== net6.0) (< netstandard1.3)) (&& (== net6.0) (< netstandard1.5)) (== netstandard2.0)
+ Microsoft.NETCore.Targets (5.0) - restriction: || (&& (== net6.0) (< netcoreapp3.1)) (&& (== net6.0) (< netstandard1.2)) (&& (== net6.0) (< netstandard1.3)) (&& (== net6.0) (< netstandard1.5)) (== netstandard2.0)
+ Microsoft.Win32.Registry (5.0)
+ System.Buffers (>= 4.5.1) - restriction: || (&& (== net6.0) (>= monoandroid) (< netstandard1.3)) (&& (== net6.0) (>= monotouch)) (&& (== net6.0) (< netcoreapp2.0)) (&& (== net6.0) (>= xamarinios)) (&& (== net6.0) (>= xamarinmac)) (&& (== net6.0) (>= xamarintvos)) (&& (== net6.0) (>= xamarinwatchos)) (== netstandard2.0)
+ System.Memory (>= 4.5.4) - restriction: || (&& (== net6.0) (< netcoreapp2.0)) (&& (== net6.0) (< netcoreapp2.1)) (&& (== net6.0) (>= uap10.1)) (== netstandard2.0)
+ System.Security.AccessControl (>= 5.0)
+ System.Security.Principal.Windows (>= 5.0)
+ Microsoft.Win32.SystemEvents (6.0.1) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1))
+ Mono.Posix.NETStandard (1.0)
+ MSBuild.StructuredLogger (2.1.669)
+ Microsoft.Build (>= 16.10)
+ Microsoft.Build.Framework (>= 16.10)
+ Microsoft.Build.Tasks.Core (>= 16.10)
+ Microsoft.Build.Utilities.Core (>= 16.10)
+ Newtonsoft.Json (13.0.1)
+ NuGet.Common (6.3)
+ NuGet.Frameworks (>= 6.3)
+ NuGet.Configuration (6.3)
+ NuGet.Common (>= 6.3)
+ System.Security.Cryptography.ProtectedData (>= 4.4)
+ NuGet.Frameworks (6.3)
+ NuGet.Packaging (6.3)
+ Newtonsoft.Json (>= 13.0.1)
+ NuGet.Configuration (>= 6.3)
+ NuGet.Versioning (>= 6.3)
+ System.Security.Cryptography.Cng (>= 5.0)
+ System.Security.Cryptography.Pkcs (>= 5.0)
+ NuGet.Protocol (6.3)
+ NuGet.Packaging (>= 6.3)
+ NuGet.Versioning (6.3)
+ System.Buffers (4.5.1) - restriction: || (&& (== net6.0) (>= monoandroid) (< netstandard1.3)) (&& (== net6.0) (>= monotouch)) (&& (== net6.0) (< netcoreapp2.0)) (&& (== net6.0) (>= xamarinios)) (&& (== net6.0) (>= xamarinmac)) (&& (== net6.0) (>= xamarintvos)) (&& (== net6.0) (>= xamarinwatchos)) (== netstandard2.0)
+ System.CodeDom (6.0)
+ System.Collections.Immutable (6.0)
+ System.Memory (>= 4.5.4) - restriction: || (&& (== net6.0) (>= net461)) (== netstandard2.0)
+ System.Runtime.CompilerServices.Unsafe (>= 6.0)
+ System.Configuration.ConfigurationManager (6.0)
+ System.Security.Cryptography.ProtectedData (>= 6.0)
+ System.Security.Permissions (>= 6.0)
+ System.Drawing.Common (6.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1))
+ Microsoft.Win32.SystemEvents (>= 6.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1))
+ System.Formats.Asn1 (6.0)
+ System.Buffers (>= 4.5.1) - restriction: || (&& (== net6.0) (>= net461)) (== netstandard2.0)
+ System.Memory (>= 4.5.4) - restriction: || (&& (== net6.0) (>= net461)) (== netstandard2.0)
+ System.Memory (4.5.5)
+ System.Buffers (>= 4.5.1) - restriction: || (&& (== net6.0) (>= monotouch)) (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netcoreapp2.0)) (&& (== net6.0) (< netstandard1.1)) (&& (== net6.0) (< netstandard2.0)) (&& (== net6.0) (>= xamarinios)) (&& (== net6.0) (>= xamarinmac)) (&& (== net6.0) (>= xamarintvos)) (&& (== net6.0) (>= xamarinwatchos)) (== netstandard2.0)
+ System.Numerics.Vectors (>= 4.4) - restriction: || (&& (== net6.0) (< netcoreapp2.0)) (== netstandard2.0)
+ System.Runtime.CompilerServices.Unsafe (>= 4.5.3) - restriction: || (&& (== net6.0) (>= monotouch)) (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netcoreapp2.0)) (&& (== net6.0) (< netcoreapp2.1)) (&& (== net6.0) (< netstandard1.1)) (&& (== net6.0) (< netstandard2.0)) (&& (== net6.0) (>= uap10.1)) (&& (== net6.0) (>= xamarinios)) (&& (== net6.0) (>= xamarinmac)) (&& (== net6.0) (>= xamarintvos)) (&& (== net6.0) (>= xamarinwatchos)) (== netstandard2.0)
+ System.Numerics.Vectors (4.5) - restriction: || (&& (== net6.0) (>= net461)) (== netstandard2.0)
+ System.Reactive (5.0)
+ System.Runtime.InteropServices.WindowsRuntime (>= 4.3) - restriction: || (&& (== net6.0) (< netcoreapp3.1)) (== netstandard2.0)
+ System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: || (&& (== net6.0) (>= net472)) (&& (== net6.0) (< netcoreapp3.1)) (&& (== net6.0) (>= uap10.1)) (== netstandard2.0)
+ System.Reflection.Metadata (6.0.1)
+ System.Collections.Immutable (>= 6.0)
+ System.Resources.Extensions (6.0)
+ System.Memory (>= 4.5.4) - restriction: || (&& (== net6.0) (>= net461)) (== netstandard2.0)
+ System.Runtime (4.3.1) - restriction: || (&& (== net6.0) (< netcoreapp3.1)) (== netstandard2.0)
+ Microsoft.NETCore.Platforms (>= 1.1.1)
+ Microsoft.NETCore.Targets (>= 1.1.3)
+ System.Runtime.CompilerServices.Unsafe (6.0)
+ System.Runtime.InteropServices.WindowsRuntime (4.3) - restriction: || (&& (== net6.0) (< netcoreapp3.1)) (== netstandard2.0)
+ System.Runtime (>= 4.3)
+ System.Security.AccessControl (6.0)
+ System.Security.Principal.Windows (>= 5.0) - restriction: || (&& (== net6.0) (>= net461)) (== netstandard2.0)
+ System.Security.Cryptography.Cng (5.0)
+ System.Formats.Asn1 (>= 5.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.0))
+ System.Security.Cryptography.Pkcs (6.0.1)
+ System.Buffers (>= 4.5.1) - restriction: || (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0)
+ System.Formats.Asn1 (>= 6.0)
+ System.Memory (>= 4.5.4) - restriction: || (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0)
+ System.Security.Cryptography.Cng (>= 5.0) - restriction: || (&& (== net6.0) (< netcoreapp3.1)) (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0)
+ System.Security.Cryptography.ProtectedData (6.0)
+ System.Security.Cryptography.Xml (6.0.1)
+ System.Memory (>= 4.5.4) - restriction: == netstandard2.0
+ System.Security.AccessControl (>= 6.0)
+ System.Security.Cryptography.Pkcs (>= 6.0.1)
+ System.Security.Permissions (6.0)
+ System.Security.AccessControl (>= 6.0)
+ System.Windows.Extensions (>= 6.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1))
+ System.Security.Principal.Windows (5.0)
+ System.Text.Encoding.CodePages (6.0)
+ System.Runtime.CompilerServices.Unsafe (>= 6.0)
+ System.Text.Encodings.Web (6.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net472)) (&& (== netstandard2.0) (>= net6.0))
+ System.Runtime.CompilerServices.Unsafe (>= 6.0)
+ System.Text.Json (6.0.5) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net472)) (&& (== netstandard2.0) (>= net6.0))
+ System.Runtime.CompilerServices.Unsafe (>= 6.0)
+ System.Text.Encodings.Web (>= 6.0)
+ System.Threading.Tasks.Dataflow (6.0)
+ System.Threading.Tasks.Extensions (4.5.4) - restriction: || (&& (== net6.0) (>= net472)) (&& (== net6.0) (< netcoreapp3.1)) (&& (== net6.0) (>= uap10.1)) (== netstandard2.0)
+ System.Runtime.CompilerServices.Unsafe (>= 4.5.3) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netcoreapp2.1)) (&& (== net6.0) (< netstandard1.0)) (&& (== net6.0) (< netstandard2.0)) (&& (== net6.0) (>= wp8)) (== netstandard2.0)
+ System.Windows.Extensions (6.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1))
+ System.Drawing.Common (>= 6.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= netcoreapp3.1))
diff --git a/docs/en/requests/maintain.md b/docs/en/requests/maintain.md
index b8e8509..8d99872 100644
--- a/docs/en/requests/maintain.md
+++ b/docs/en/requests/maintain.md
@@ -14,7 +14,7 @@ If you are looking for a particular requests, enter some text in the search box
## Edit Request
-To edit a request, click the blue pencil icon; it's the first icon under the “Actions” column heading.
+To edit a request, click the pencil icon; it's the first icon under the “Actions” column heading.
## Expire a Request
@@ -26,4 +26,4 @@ When the page is first displayed, it does not display inactive requests. However
## Delete a Request
-Deleting a request is contrary to the intent of PrayerTracker, as you can retrieve requests that have expired. However, if there is a request that needs to be deleted, clicking the blue trash can icon in the “Actions” column will allow you to do it. Use this option carefully, as these deletions cannot be undone; once a request is deleted, it is gone for good.
+Deleting a request is contrary to the intent of PrayerTracker, as you can retrieve requests that have expired. However, if there is a request that needs to be deleted, clicking the trash can icon in the “Actions” column will allow you to do it. Use this option carefully, as these deletions cannot be undone; once a request is deleted, it is gone for good.
diff --git a/docs/en/small-group/members.md b/docs/en/small-group/members.md
index c387215..99fb20d 100644
--- a/docs/en/small-group/members.md
+++ b/docs/en/small-group/members.md
@@ -10,8 +10,8 @@ To add an e-mail address, click the icon or text in the center of the page, belo
## Edit Group Member
-To edit an e-mail address, click the blue pencil icon; it's the first icon under the “Actions” column heading. This will allow you to update the name and/or the e-mail address for that member.
+To edit an e-mail address, click the pencil icon; it's the first icon under the “Actions” column heading. This will allow you to update the name and/or the e-mail address for that member.
## Delete a Group Member
-To delete an e-mail address, click the blue trash can icon in the “Actions” column. Note that once an e-mail address has been deleted, it is gone. (Of course, if you delete it in error, you can enter it again using the “Add” instructions above.)
+To delete an e-mail address, click the trash can icon in the “Actions” column. Note that once an e-mail address has been deleted, it is gone. (Of course, if you delete it in error, you can enter it again using the “Add” instructions above.)
diff --git a/docs/en/small-group/preferences.md b/docs/en/small-group/preferences.md
index 1c3b137..54c68cd 100644
--- a/docs/en/small-group/preferences.md
+++ b/docs/en/small-group/preferences.md
@@ -34,7 +34,10 @@ You can customize the colors that are used for the headings and lines in your re
## Fonts for List
-This is a comma-separated list of fonts that will be used for your request list. A warning is good here; just because you have an obscure font and like the way that it looks does not mean that others have that same font. It is generally best to stick with the fonts that come with Windows - fonts like “Arial”, “Times New Roman”, “Tahoma”, and “Comic Sans MS”. You should also end the font list with either “serif” or “sans-serif”, which will use the browser's default serif (like “Times New Roman”) or sans-serif (like “Arial”) font.
+There are two options for fonts that will be used in the prayer request list.
+
+* “Native Fonts” uses a list of fonts that will render the prayer requests in the best available font for their device, whether that is a desktop or laptop computer, mobile device, or tablet. (This is the default for new small groups.)
+* “Named Fonts” uses a comma-separated list of fonts that you specify. A warning is good here; just because you have an obscure font and like the way that it looks does not mean that others have that same font. It is generally best to stick with the fonts that come with Windows - fonts like “Arial”, “Times New Roman”, “Tahoma”, and “Comic Sans MS”. You should also end the font list with either “serif” or “sans-serif”, which will use the browser's default serif (like “Times New Roman”) or sans-serif (like “Arial”) font.
## Heading / List Text Size
@@ -44,23 +47,23 @@ This is the point size to use for each. The default for the heading is 16pt, and
If your group is comprised mostly of people who prefer large print, the following settings will make your list look like the typical large-print publication:
-> _Fonts_
-> — 'Times New Roman',serif
+> **Fonts**
+> Named Fonts: "Times New Roman",serif
>
-> _Heading Text Size_
-> — 18pt
+> **Heading Text Size**
+> 18pt
>
-> _List Text Size_
-> — 16pt
-
-## Time Zone
-
-This is the time zone that you would like to use for your group. If you do not see your time zone listed, just [contact Daniel](mailto:daniel@djs-consulting.com?subject=PrayerTracker%20Time%20Zone) and tell him what time zone you need.
+> **List Text Size**
+> 16pt
## Request List Visibility
The group's request list can be either public, private, or password-protected. Public lists are available without logging in, and private lists are only available online to administrators (though the list can still be sent via e-mail by an administrator). Password-protected lists allow group members to log in and view the current request list online, using the “Group Log On” link and providing this password. As this is a shared password, it is stored in plain text, so you can easily see what it is. If you select “Password Protected” but do not enter a password, the list remains private, which is also the default value. (Changing this password will force all members of the group who logged in with the “Remember Me” box checked to provide the new password.)
+## Time Zone
+
+This is the time zone that you would like to use for your group. If you do not see your time zone listed, just [contact Daniel](mailto:daniel@bitbadger.solutions?subject=PrayerTracker%20Time%20Zone) and tell him what time zone you need.
+
## Page Size
As small groups use PrayerTracker, they accumulate many expired requests. When lists of requests that include expired requests, the results will be broken up into pages. The default value is 100 requests per page, but may be set as low as 10 or as high as 255.
diff --git a/docs/en/user/password.md b/docs/en/user/password.md
index 3b5f2df..6261f3f 100644
--- a/docs/en/user/password.md
+++ b/docs/en/user/password.md
@@ -4,4 +4,4 @@ title: Change Your Password
This page will let you change your password. Enter your existing password in the top box, then enter your new password in the bottom two boxes. Entering your existing password is a security measure; with the “Remember Me” box on the log in page, this will prevent someone else who may be using your computer from being able to simply go to the site and change your password.
-"If you cannot remember your existing password, we cannot retrieve it, but we can set it to something known so that you can then change it to your password. [Click here to request help resetting your password](mailto:daniel@djs-consulting.com?subject=PrayerTracker%20Password%20Help).
+"If you cannot remember your existing password, we cannot retrieve it, but we can set it to something known so that you can then change it to your password. [Click here to request help resetting your password](mailto:daniel@bitbadger.solutions?subject=PrayerTracker%20Password%20Help).
diff --git a/docs/es/requests/maintain.md b/docs/es/requests/maintain.md
index 470cc9f..9e78471 100644
--- a/docs/es/requests/maintain.md
+++ b/docs/es/requests/maintain.md
@@ -14,7 +14,7 @@ Si está buscando una solicitud en particular, ingrese un texto en el cuadro de
## Editar la Petición
-Para editar una petición, haga clic en el icono de lápiz azul, el primer icono bajo el título de columna “Acciones”.
+Para editar una petición, haga clic en el icono de lápiz, el primer icono bajo el título de columna “Acciones”.
## Expirar una petición
@@ -26,4 +26,4 @@ Cuando la página se muestra por primera vez, que no muestra peticiones inactivo
## Eliminar una Petición
-Eliminación de una petición es contraria a la intención de SeguidorOración, como se puede recuperar peticiones que han expirado. Sin embargo, si hay una solicitud que debe ser eliminado, haga clic en el icono azul de la papelera en la columna “Acciones” le permitirá hacerlo. Utilice esta opción con cuidado, ya que estas supresiones no se puede deshacer, una vez a la petición se ha borrado, ha desaparecido para siempre.
\ No newline at end of file
+Eliminación de una petición es contraria a la intención de SeguidorOración, como se puede recuperar peticiones que han expirado. Sin embargo, si hay una solicitud que debe ser eliminado, haga clic en el icono de la papelera en la columna “Acciones” le permitirá hacerlo. Utilice esta opción con cuidado, ya que estas supresiones no se puede deshacer, una vez a la petición se ha borrado, ha desaparecido para siempre.
\ No newline at end of file
diff --git a/docs/es/small-group/members.md b/docs/es/small-group/members.md
index e7fe766..50b1fca 100644
--- a/docs/es/small-group/members.md
+++ b/docs/es/small-group/members.md
@@ -10,8 +10,8 @@ Para agregar una dirección de correo electrónico, haga clic en el icono o el t
## Editar el Miembro del Grupo
-Para editar una dirección de correo electrónico, haga clic en el icono de lápiz azul, es el primer icono bajo el título de columna “Acciones”. Esto le permitirá actualizar el nombre y / o la dirección de correo electrónico para ese miembro.
+Para editar una dirección de correo electrónico, haga clic en el icono de lápiz, es el primer icono bajo el título de columna “Acciones”. Esto le permitirá actualizar el nombre y / o la dirección de correo electrónico para ese miembro.
## Eliminar un Miembro del Grupo
-Para eliminar una dirección de correo electrónico, haga clic en el icono azul de la papelera en la columna “Acciones”. Tenga en cuenta que una vez que la dirección de correo electrónico se ha eliminado, se ha ido. (Por supuesto, si usted lo elimine por error, se puede entrar de nuevo utilizando la opción “Agregar” instrucciones de arriba.)
+Para eliminar una dirección de correo electrónico, haga clic en el icono de la papelera en la columna “Acciones”. Tenga en cuenta que una vez que la dirección de correo electrónico se ha eliminado, se ha ido. (Por supuesto, si usted lo elimine por error, se puede entrar de nuevo utilizando la opción “Agregar” instrucciones de arriba.)
diff --git a/docs/es/small-group/preferences.md b/docs/es/small-group/preferences.md
index 3a46129..ac3e12a 100644
--- a/docs/es/small-group/preferences.md
+++ b/docs/es/small-group/preferences.md
@@ -34,7 +34,10 @@ Usted puede personalizar los colores que se utilizan para las partidas y líneas
## Fuentes de la Lista
-Esta es una lista separada por comas de fuentes que se utilizarán para su lista de peticiones. Una advertencia de que es bueno aquí, sólo porque usted tiene una fuente oscura y gusta la forma en que se vea no significa que los demás tienen de que la misma fuente. Generalmente es mejor quedarse con las fuentes que vienen con Windows - Fuentes como “Arial”, “Times New Roman”, “Tahoma”, y “Comic Sans MS”. También debe poner fin a la lista de fuentes, ya sea con “serif” o el “sans-serif”, que utilizará el fuente serif predeterminado (como “Times New Roman”) o el fuente sans-serif predeterminado (como “Arial”).
+Hay dos opciones para las fuentes que se utilizarán en la lista de peticiones de oración.
+
+* “Fuentes Nativas” utiliza una lista de fuentes que representarán las peticiones de oración en la mejor fuente disponible para su dispositivo, ya sea una computadora de escritorio o portátil, un dispositivo móvil o una tableta. (Este es el valor predeterminado para los nuevos grupos pequeños).
+* “Fuentes con Nombre” utiliza una lista de fuentes separadas por comas que usted especifica. Una advertencia de que es bueno aquí, sólo porque usted tiene una fuente oscura y gusta la forma en que se vea no significa que los demás tienen de que la misma fuente. Generalmente es mejor quedarse con las fuentes que vienen con Windows - Fuentes como “Arial”, “Times New Roman”, “Tahoma”, y “Comic Sans MS”. También debe poner fin a la lista de fuentes, ya sea con “serif” o el “sans-serif”, que utilizará el fuente serif predeterminado (como “Times New Roman”) o el fuente sans-serif predeterminado (como “Arial”).
## Tamaño del Texto de Partida y Lista
@@ -44,23 +47,23 @@ Este es el tamaño de punto a utilizar para cada uno. El valor predeterminado pa
Si el grupo está compuesta en su mayoría de la gente que prefiere letras grandes, los siguientes ajustes harán que su lista de parecerse a la típica la publicación “Letra Grande”:
-> _Fuentes_
-> — 'Times New Roman',serif
+> **Fuentes**
+> Fuentes con Nombre: "Times New Roman",serif
>
-> _Partida el Tamaño del Texto_
-> — 18pt
+> **Partida el Tamaño del Texto**
+> 18pt
>
-> _Lista el Tamaño del Texto_
-> — 16pt
-
-## Zona Horaria
-
-Esta es la zona horaria que desea utilizar para su clase. Si no puede ver la zona horaria en la lista, ponte en [contacto con Daniel](mailto:daniel@djs-consulting.com?subject=Zona%20Horaria%20por%20SeguidorOración) y decirle lo que la zona horaria que usted necesita.
+> **Lista el Tamaño del Texto**
+> 16pt
## La Visibilidad del la Lista de las Peticiones
La lista de peticiones del grupo puede ser pública, privada o protegida por contraseña. Las listas públicas están disponibles sin iniciar sesión, y listas privadas sólo están disponibles en línea a los administradores (aunque la lista todavía puede ser enviado por correo electrónico por el administrador). Protegidos con contraseña listas permiten miembros del grupo iniciar sesión y ver la lista de peticiones actual en el sito, utilizando el "Iniciar Sesión como Grupo" enlace y proporcionar la contraseña. Como se trata de una contraseña compartida, se almacena en texto plano, así que usted puede ver fácilmente lo que es. Si selecciona "Protegido por Contraseña" pero no introduce una contraseña, la lista sigue siendo privado, que también es el valor predeterminado. (Cambiar esta contraseña obligará a todos los miembros del grupo que se iniciar sesión en el "Acuérdate de Mí" caja marcada para proporcionar la nueva contraseña.)
+## Zona Horaria
+
+Esta es la zona horaria que desea utilizar para su clase. Si no puede ver la zona horaria en la lista, ponte en [contacto con Daniel](mailto:daniel@bitbadger.solutions?subject=Zona%20Horaria%20por%20SeguidorOración) y decirle lo que la zona horaria que usted necesita.
+
## Tamaño de Página
A medida que los grupos pequeños utilizan SeguidorOración, acumulan muchas solicitudes caducadas. Cuando las listas de solicitudes que incluyen solicitudes caducadas, los resultados se dividirán en páginas. El valor predeterminado es de 100 solicitudes por página, pero se puede establecer tan bajo como 10 o tan alto como 255.
diff --git a/docs/es/user/password.md b/docs/es/user/password.md
index 19d2350..71f7eeb 100644
--- a/docs/es/user/password.md
+++ b/docs/es/user/password.md
@@ -4,4 +4,4 @@ title: Cambiar Su Contraseña
Esta página le permitirá cambiar su contraseña. Ingrese su contraseña actual en la caja superior y introduzca la nueva contraseña en la parte inferior dos cajas. Al entrar su contraseña actual es una medida de seguridad, con el “Acuérdate de Mí” caja de la página inicio de sesión, esto evitará que otra persona que pueda estar usando su computadora de la posibilidad de simplemente ir a el sitio y cambiar la contraseña.
-Si no recuerdas tu contraseña actual, no podemos recuperar, pero podemos ponerlo en algo que se conoce de modo que usted puede cambiarlo a su contraseña. [Haga clic aquí para solicitar ayuda para restablecer su contraseña](mailto:daniel@djs-consulting.com?subject=Ayuda%20de%20Contraseña%20de%20SeguidorOración).
+Si no recuerdas tu contraseña actual, no podemos recuperar, pero podemos ponerlo en algo que se conoce de modo que usted puede cambiarlo a su contraseña. [Haga clic aquí para solicitar ayuda para restablecer su contraseña](mailto:daniel@bitbadger.solutions?subject=Ayuda%20de%20Contraseña%20de%20SeguidorOración).
diff --git a/fake.cmd b/fake.cmd
new file mode 100644
index 0000000..72bbc3e
--- /dev/null
+++ b/fake.cmd
@@ -0,0 +1,2 @@
+dotnet tool restore
+dotnet fake %*
\ No newline at end of file
diff --git a/fake.sh b/fake.sh
new file mode 100755
index 0000000..bc92bc9
--- /dev/null
+++ b/fake.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+set -eu
+set -o pipefail
+
+dotnet tool restore
+dotnet fake "$@"
\ No newline at end of file
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 27de438..d54687e 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -1,9 +1,11 @@
- 7.6.1.0
- 7.6.1.0
+ net6.0
+ 8.0.0.0
+ 8.0.0.0
danieljsummers
Bit Badger Solutions
- 7.6.1
+ 8.0.0
+ Embedded
diff --git a/src/PrayerTracker.Data/Access.fs b/src/PrayerTracker.Data/Access.fs
new file mode 100644
index 0000000..28c2167
--- /dev/null
+++ b/src/PrayerTracker.Data/Access.fs
@@ -0,0 +1,724 @@
+namespace PrayerTracker.Data
+
+open NodaTime
+open Npgsql
+open Npgsql.FSharp
+open PrayerTracker.Entities
+
+/// Helper functions for the PostgreSQL data implementation
+[]
+module private Helpers =
+
+ /// Map a row to a Church instance
+ let mapToChurch (row : RowReader) =
+ { Id = ChurchId (row.uuid "id")
+ Name = row.string "church_name"
+ City = row.string "city"
+ State = row.string "state"
+ HasVpsInterface = row.bool "has_vps_interface"
+ InterfaceAddress = row.stringOrNone "interface_address"
+ }
+
+ /// Map a row to a ListPreferences instance
+ let mapToListPreferences (row : RowReader) =
+ { SmallGroupId = SmallGroupId (row.uuid "small_group_id")
+ DaysToKeepNew = row.int "days_to_keep_new"
+ DaysToExpire = row.int "days_to_expire"
+ LongTermUpdateWeeks = row.int "long_term_update_weeks"
+ EmailFromName = row.string "email_from_name"
+ EmailFromAddress = row.string "email_from_address"
+ Fonts = row.string "fonts"
+ HeadingColor = row.string "heading_color"
+ LineColor = row.string "line_color"
+ HeadingFontSize = row.int "heading_font_size"
+ TextFontSize = row.int "text_font_size"
+ GroupPassword = row.string "group_password"
+ IsPublic = row.bool "is_public"
+ PageSize = row.int "page_size"
+ TimeZoneId = TimeZoneId (row.string "time_zone_id")
+ RequestSort = RequestSort.fromCode (row.string "request_sort")
+ DefaultEmailType = EmailFormat.fromCode (row.string "default_email_type")
+ AsOfDateDisplay = AsOfDateDisplay.fromCode (row.string "as_of_date_display")
+ }
+
+ /// Map a row to a Member instance
+ let mapToMember (row : RowReader) =
+ { Id = MemberId (row.uuid "id")
+ SmallGroupId = SmallGroupId (row.uuid "small_group_id")
+ Name = row.string "member_name"
+ Email = row.string "email"
+ Format = row.stringOrNone "email_format" |> Option.map EmailFormat.fromCode
+ }
+
+ /// Map a row to a Prayer Request instance
+ let mapToPrayerRequest (row : RowReader) =
+ { Id = PrayerRequestId (row.uuid "id")
+ UserId = UserId (row.uuid "user_id")
+ SmallGroupId = SmallGroupId (row.uuid "small_group_id")
+ EnteredDate = row.fieldValue "entered_date"
+ UpdatedDate = row.fieldValue "updated_date"
+ Requestor = row.stringOrNone "requestor"
+ Text = row.string "request_text"
+ NotifyChaplain = row.bool "notify_chaplain"
+ RequestType = PrayerRequestType.fromCode (row.string "request_type")
+ Expiration = Expiration.fromCode (row.string "expiration")
+ }
+
+ /// Map a row to a Small Group instance
+ let mapToSmallGroup (row : RowReader) =
+ { Id = SmallGroupId (row.uuid "id")
+ ChurchId = ChurchId (row.uuid "church_id")
+ Name = row.string "group_name"
+ Preferences = ListPreferences.empty
+ }
+
+ /// Map a row to a Small Group information set
+ let mapToSmallGroupInfo (row : RowReader) =
+ { Id = Giraffe.ShortGuid.fromGuid (row.uuid "id")
+ Name = row.string "group_name"
+ ChurchName = row.string "church_name"
+ TimeZoneId = TimeZoneId (row.string "time_zone_id")
+ IsPublic = row.bool "is_public"
+ }
+
+ /// Map a row to a Small Group list item
+ let mapToSmallGroupItem (row : RowReader) =
+ Giraffe.ShortGuid.fromGuid (row.uuid "id"), $"""{row.string "church_name"} | {row.string "group_name"}"""
+
+ /// Map a row to a Small Group instance with populated list preferences
+ let mapToSmallGroupWithPreferences (row : RowReader) =
+ { mapToSmallGroup row with
+ Preferences = mapToListPreferences row
+ }
+
+ /// Map a row to a User instance
+ let mapToUser (row : RowReader) =
+ { Id = UserId (row.uuid "id")
+ FirstName = row.string "first_name"
+ LastName = row.string "last_name"
+ Email = row.string "email"
+ IsAdmin = row.bool "is_admin"
+ PasswordHash = row.string "password_hash"
+ LastSeen = row.fieldValueOrNone "last_seen"
+ }
+
+
+/// Functions to manipulate churches
+module Churches =
+
+ /// Get a list of all churches
+ let all conn =
+ Sql.existingConnection conn
+ |> Sql.query "SELECT * FROM pt.church ORDER BY church_name"
+ |> Sql.executeAsync mapToChurch
+
+ /// Delete a church by its ID
+ let deleteById (churchId : ChurchId) conn = backgroundTask {
+ let idParam = [ [ "@churchId", Sql.uuid churchId.Value ] ]
+ let where = "WHERE small_group_id IN (SELECT id FROM pt.small_group WHERE church_id = @churchId)"
+ let! _ =
+ Sql.existingConnection conn
+ |> Sql.executeTransactionAsync
+ [ $"DELETE FROM pt.prayer_request {where}", idParam
+ $"DELETE FROM pt.user_small_group {where}", idParam
+ $"DELETE FROM pt.list_preference {where}", idParam
+ "DELETE FROM pt.small_group WHERE church_id = @churchId", idParam
+ "DELETE FROM pt.church WHERE id = @churchId", idParam ]
+ return ()
+ }
+
+ /// Save a church's information
+ let save (church : Church) conn = backgroundTask {
+ let! _ =
+ Sql.existingConnection conn
+ |> Sql.query """
+ INSERT INTO pt.church (
+ id, church_name, city, state, has_vps_interface, interface_address
+ ) VALUES (
+ @id, @name, @city, @state, @hasVpsInterface, @interfaceAddress
+ ) ON CONFLICT (id) DO UPDATE
+ SET church_name = EXCLUDED.church_name,
+ city = EXCLUDED.city,
+ state = EXCLUDED.state,
+ has_vps_interface = EXCLUDED.has_vps_interface,
+ interface_address = EXCLUDED.interface_address"""
+ |> Sql.parameters
+ [ "@id", Sql.uuid church.Id.Value
+ "@name", Sql.string church.Name
+ "@city", Sql.string church.City
+ "@state", Sql.string church.State
+ "@hasVpsInterface", Sql.bool church.HasVpsInterface
+ "@interfaceAddress", Sql.stringOrNone church.InterfaceAddress ]
+ |> Sql.executeNonQueryAsync
+ return ()
+ }
+
+ /// Find a church by its ID
+ let tryById (churchId : ChurchId) conn = backgroundTask {
+ let! church =
+ Sql.existingConnection conn
+ |> Sql.query "SELECT * FROM pt.church WHERE id = @id"
+ |> Sql.parameters [ "@id", Sql.uuid churchId.Value ]
+ |> Sql.executeAsync mapToChurch
+ return List.tryHead church
+ }
+
+
+/// Functions to manipulate small group members
+module Members =
+
+ /// Count members for the given small group
+ let countByGroup (groupId : SmallGroupId) conn =
+ Sql.existingConnection conn
+ |> Sql.query "SELECT COUNT(id) AS mbr_count FROM pt.member WHERE small_group_id = @groupId"
+ |> Sql.parameters [ "@groupId", Sql.uuid groupId.Value ]
+ |> Sql.executeRowAsync (fun row -> row.int "mbr_count")
+
+ /// Delete a small group member by its ID
+ let deleteById (memberId : MemberId) conn = backgroundTask {
+ let! _ =
+ Sql.existingConnection conn
+ |> Sql.query "DELETE FROM pt.member WHERE id = @id"
+ |> Sql.parameters [ "@id", Sql.uuid memberId.Value ]
+ |> Sql.executeNonQueryAsync
+ return ()
+ }
+
+ /// Retrieve all members for a given small group
+ let forGroup (groupId : SmallGroupId) conn =
+ Sql.existingConnection conn
+ |> Sql.query "SELECT * FROM pt.member WHERE small_group_id = @groupId ORDER BY member_name"
+ |> Sql.parameters [ "@groupId", Sql.uuid groupId.Value ]
+ |> Sql.executeAsync mapToMember
+
+ /// Save a small group member
+ let save (mbr : Member) conn = backgroundTask {
+ let! _ =
+ Sql.existingConnection conn
+ |> Sql.query """
+ INSERT INTO pt.member (
+ id, small_group_id, member_name, email, email_format
+ ) VALUES (
+ @id, @groupId, @name, @email, @format
+ ) ON CONFLICT (id) DO UPDATE
+ SET member_name = EXCLUDED.member_name,
+ email = EXCLUDED.email,
+ email_format = EXCLUDED.email_format"""
+ |> Sql.parameters
+ [ "@id", Sql.uuid mbr.Id.Value
+ "@groupId", Sql.uuid mbr.SmallGroupId.Value
+ "@name", Sql.string mbr.Name
+ "@email", Sql.string mbr.Email
+ "@format", Sql.stringOrNone (mbr.Format |> Option.map EmailFormat.toCode) ]
+ |> Sql.executeNonQueryAsync
+ return ()
+ }
+
+ /// Retrieve a small group member by its ID
+ let tryById (memberId : MemberId) conn = backgroundTask {
+ let! mbr =
+ Sql.existingConnection conn
+ |> Sql.query "SELECT * FROM pt.member WHERE id = @id"
+ |> Sql.parameters [ "@id", Sql.uuid memberId.Value ]
+ |> Sql.executeAsync mapToMember
+ return List.tryHead mbr
+ }
+
+
+/// Options to retrieve a list of requests
+type PrayerRequestOptions =
+ { /// The small group for which requests should be retrieved
+ SmallGroup : SmallGroup
+
+ /// The clock instance to use for date/time manipulation
+ Clock : IClock
+
+ /// The date for which the list is being retrieved
+ ListDate : LocalDate option
+
+ /// Whether only active requests should be retrieved
+ ActiveOnly : bool
+
+ /// The page number, for paged lists
+ PageNumber : int
+ }
+
+
+/// Functions to manipulate prayer requests
+module PrayerRequests =
+
+ /// Central place to append sort criteria for prayer request queries
+ let private orderBy sort =
+ match sort with
+ | SortByDate -> "updated_date DESC, entered_date DESC, requestor"
+ | SortByRequestor -> "requestor, updated_date DESC, entered_date DESC"
+
+ /// Paginate a prayer request query
+ let private paginate (pageNbr : int) pageSize =
+ if pageNbr > 0 then $"LIMIT {pageSize} OFFSET {(pageNbr - 1) * pageSize}" else ""
+
+ /// Count the number of prayer requests for a church
+ let countByChurch (churchId : ChurchId) conn =
+ Sql.existingConnection conn
+ |> Sql.query """
+ SELECT COUNT(id) AS req_count
+ FROM pt.prayer_request
+ WHERE small_group_id IN (SELECT id FROM pt.small_group WHERE church_id = @churchId)"""
+ |> Sql.parameters [ "@churchId", Sql.uuid churchId.Value ]
+ |> Sql.executeRowAsync (fun row -> row.int "req_count")
+
+ /// Count the number of prayer requests for a small group
+ let countByGroup (groupId : SmallGroupId) conn =
+ Sql.existingConnection conn
+ |> Sql.query "SELECT COUNT(id) AS req_count FROM pt.prayer_request WHERE small_group_id = @groupId"
+ |> Sql.parameters [ "@groupId", Sql.uuid groupId.Value ]
+ |> Sql.executeRowAsync (fun row -> row.int "req_count")
+
+ /// Delete a prayer request by its ID
+ let deleteById (reqId : PrayerRequestId) conn = backgroundTask {
+ let! _ =
+ Sql.existingConnection conn
+ |> Sql.query "DELETE FROM pt.prayer_request WHERE id = @id"
+ |> Sql.parameters [ "@id", Sql.uuid reqId.Value ]
+ |> Sql.executeNonQueryAsync
+ return ()
+ }
+
+ /// Get all (or active) requests for a small group as of now or the specified date
+ let forGroup (opts : PrayerRequestOptions) conn =
+ let theDate = defaultArg opts.ListDate (SmallGroup.localDateNow opts.Clock opts.SmallGroup)
+ let where, parameters =
+ if opts.ActiveOnly then
+ let asOf = NpgsqlParameter (
+ "@asOf",
+ (theDate.AtStartOfDayInZone(SmallGroup.timeZone opts.SmallGroup)
+ - Duration.FromDays opts.SmallGroup.Preferences.DaysToExpire)
+ .ToInstant ())
+ """ AND ( updated_date > @asOf
+ OR expiration = @manual
+ OR request_type = @longTerm
+ OR request_type = @expecting)
+ AND expiration <> @forced""",
+ [ "@asOf", Sql.parameter asOf
+ "@manual", Sql.string (Expiration.toCode Manual)
+ "@longTerm", Sql.string (PrayerRequestType.toCode LongTermRequest)
+ "@expecting", Sql.string (PrayerRequestType.toCode Expecting)
+ "@forced", Sql.string (Expiration.toCode Forced) ]
+ else "", []
+ Sql.existingConnection conn
+ |> Sql.query $"""
+ SELECT *
+ FROM pt.prayer_request
+ WHERE small_group_id = @groupId {where}
+ ORDER BY {orderBy opts.SmallGroup.Preferences.RequestSort}
+ {paginate opts.PageNumber opts.SmallGroup.Preferences.PageSize}"""
+ |> Sql.parameters (("@groupId", Sql.uuid opts.SmallGroup.Id.Value) :: parameters)
+ |> Sql.executeAsync mapToPrayerRequest
+
+ /// Save a prayer request
+ let save (req : PrayerRequest) conn = backgroundTask {
+ let! _ =
+ Sql.existingConnection conn
+ |> Sql.query """
+ INSERT into pt.prayer_request (
+ id, request_type, user_id, small_group_id, entered_date, updated_date, requestor, request_text,
+ notify_chaplain, expiration
+ ) VALUES (
+ @id, @type, @userId, @groupId, @entered, @updated, @requestor, @text,
+ @notifyChaplain, @expiration
+ ) ON CONFLICT (id) DO UPDATE
+ SET request_type = EXCLUDED.request_type,
+ updated_date = EXCLUDED.updated_date,
+ requestor = EXCLUDED.requestor,
+ request_text = EXCLUDED.request_text,
+ notify_chaplain = EXCLUDED.notify_chaplain,
+ expiration = EXCLUDED.expiration"""
+ |> Sql.parameters
+ [ "@id", Sql.uuid req.Id.Value
+ "@type", Sql.string (PrayerRequestType.toCode req.RequestType)
+ "@userId", Sql.uuid req.UserId.Value
+ "@groupId", Sql.uuid req.SmallGroupId.Value
+ "@entered", Sql.parameter (NpgsqlParameter ("@entered", req.EnteredDate))
+ "@updated", Sql.parameter (NpgsqlParameter ("@updated", req.UpdatedDate))
+ "@requestor", Sql.stringOrNone req.Requestor
+ "@text", Sql.string req.Text
+ "@notifyChaplain", Sql.bool req.NotifyChaplain
+ "@expiration", Sql.string (Expiration.toCode req.Expiration)
+ ]
+ |> Sql.executeNonQueryAsync
+ return ()
+ }
+
+ /// Search prayer requests for the given term
+ let searchForGroup group searchTerm pageNbr conn =
+ Sql.existingConnection conn
+ |> Sql.query $"""
+ SELECT * FROM pt.prayer_request WHERE small_group_id = @groupId AND request_text ILIKE @search
+ UNION
+ SELECT * FROM pt.prayer_request WHERE small_group_id = @groupId AND COALESCE(requestor, '') ILIKE @search
+ ORDER BY {orderBy group.Preferences.RequestSort}
+ {paginate pageNbr group.Preferences.PageSize}"""
+ |> Sql.parameters [ "@groupId", Sql.uuid group.Id.Value; "@search", Sql.string $"%%%s{searchTerm}%%" ]
+ |> Sql.executeAsync mapToPrayerRequest
+
+ /// Retrieve a prayer request by its ID
+ let tryById (reqId : PrayerRequestId) conn = backgroundTask {
+ let! req =
+ Sql.existingConnection conn
+ |> Sql.query "SELECT * FROM pt.prayer_request WHERE id = @id"
+ |> Sql.parameters [ "@id", Sql.uuid reqId.Value ]
+ |> Sql.executeAsync mapToPrayerRequest
+ return List.tryHead req
+ }
+
+ /// Update the expiration for the given prayer request
+ let updateExpiration (req : PrayerRequest) withTime conn = backgroundTask {
+ let sql, parameters =
+ if withTime then
+ ", updated_date = @updated",
+ [ "@updated", Sql.parameter (NpgsqlParameter ("@updated", req.UpdatedDate)) ]
+ else "", []
+ let! _ =
+ Sql.existingConnection conn
+ |> Sql.query $"UPDATE pt.prayer_request SET expiration = @expiration{sql} WHERE id = @id"
+ |> Sql.parameters
+ ([ "@expiration", Sql.string (Expiration.toCode req.Expiration)
+ "@id", Sql.uuid req.Id.Value ]
+ |> List.append parameters)
+ |> Sql.executeNonQueryAsync
+ return ()
+ }
+
+
+/// Functions to retrieve small group information
+module SmallGroups =
+
+ /// Count the number of small groups for a church
+ let countByChurch (churchId : ChurchId) conn =
+ Sql.existingConnection conn
+ |> Sql.query "SELECT COUNT(id) AS group_count FROM pt.small_group WHERE church_id = @churchId"
+ |> Sql.parameters [ "@churchId", Sql.uuid churchId.Value ]
+ |> Sql.executeRowAsync (fun row -> row.int "group_count")
+
+ /// Delete a small group by its ID
+ let deleteById (groupId : SmallGroupId) conn = backgroundTask {
+ let idParam = [ [ "@groupId", Sql.uuid groupId.Value ] ]
+ let! _ =
+ Sql.existingConnection conn
+ |> Sql.executeTransactionAsync
+ [ "DELETE FROM pt.prayer_request WHERE small_group_id = @groupId", idParam
+ "DELETE FROM pt.user_small_group WHERE small_group_id = @groupId", idParam
+ "DELETE FROM pt.list_preference WHERE small_group_id = @groupId", idParam
+ "DELETE FROM pt.small_group WHERE id = @groupId", idParam ]
+ return ()
+ }
+
+ /// Get information for all small groups
+ let infoForAll conn =
+ Sql.existingConnection conn
+ |> Sql.query """
+ SELECT sg.id, sg.group_name, c.church_name, lp.time_zone_id, lp.is_public
+ FROM pt.small_group sg
+ INNER JOIN pt.church c ON c.id = sg.church_id
+ INNER JOIN pt.list_preference lp ON lp.small_group_id = sg.id
+ ORDER BY sg.group_name"""
+ |> Sql.executeAsync mapToSmallGroupInfo
+
+ /// Get a list of small group IDs along with a description that includes the church name
+ let listAll conn =
+ Sql.existingConnection conn
+ |> Sql.query """
+ SELECT g.group_name, g.id, c.church_name
+ FROM pt.small_group g
+ INNER JOIN pt.church c ON c.id = g.church_id
+ ORDER BY c.church_name, g.group_name"""
+ |> Sql.executeAsync mapToSmallGroupItem
+
+ /// Get a list of small group IDs and descriptions for groups with a group password
+ let listProtected conn =
+ Sql.existingConnection conn
+ |> Sql.query """
+ SELECT g.group_name, g.id, c.church_name, lp.is_public
+ FROM pt.small_group g
+ INNER JOIN pt.church c ON c.id = g.church_id
+ INNER JOIN pt.list_preference lp ON lp.small_group_id = g.id
+ WHERE COALESCE(lp.group_password, '') <> ''
+ ORDER BY c.church_name, g.group_name"""
+ |> Sql.executeAsync mapToSmallGroupItem
+
+ /// Get a list of small group IDs and descriptions for groups that are public or have a group password
+ let listPublicAndProtected conn =
+ Sql.existingConnection conn
+ |> Sql.query """
+ SELECT g.group_name, g.id, c.church_name, lp.time_zone_id, lp.is_public
+ FROM pt.small_group g
+ INNER JOIN pt.church c ON c.id = g.church_id
+ INNER JOIN pt.list_preference lp ON lp.small_group_id = g.id
+ WHERE lp.is_public = TRUE
+ OR COALESCE(lp.group_password, '') <> ''
+ ORDER BY c.church_name, g.group_name"""
+ |> Sql.executeAsync mapToSmallGroupInfo
+
+ /// Log on for a small group (includes list preferences)
+ let logOn (groupId : SmallGroupId) password conn = backgroundTask {
+ let! group =
+ Sql.existingConnection conn
+ |> Sql.query """
+ SELECT sg.*, lp.*
+ FROM pt.small_group sg
+ INNER JOIN pt.list_preference lp ON lp.small_group_id = sg.id
+ WHERE sg.id = @id
+ AND lp.group_password = @password"""
+ |> Sql.parameters [ "@id", Sql.uuid groupId.Value; "@password", Sql.string password ]
+ |> Sql.executeAsync mapToSmallGroupWithPreferences
+ return List.tryHead group
+ }
+
+ /// Save a small group
+ let save (group : SmallGroup) isNew conn = backgroundTask {
+ let! _ =
+ Sql.existingConnection conn
+ |> Sql.executeTransactionAsync [
+ """ INSERT INTO pt.small_group (
+ id, church_id, group_name
+ ) VALUES (
+ @id, @churchId, @name
+ ) ON CONFLICT (id) DO UPDATE
+ SET church_id = EXCLUDED.church_id,
+ group_name = EXCLUDED.group_name""",
+ [ [ "@id", Sql.uuid group.Id.Value
+ "@churchId", Sql.uuid group.ChurchId.Value
+ "@name", Sql.string group.Name ] ]
+ if isNew then
+ "INSERT INTO pt.list_preference (small_group_id) VALUES (@id)",
+ [ [ "@id", Sql.uuid group.Id.Value ] ]
+ ]
+ return ()
+ }
+
+ /// Save a small group's list preferences
+ let savePreferences (pref : ListPreferences) conn = backgroundTask {
+ let! _ =
+ Sql.existingConnection conn
+ |> Sql.query """
+ UPDATE pt.list_preference
+ SET days_to_keep_new = @daysToKeepNew,
+ days_to_expire = @daysToExpire,
+ long_term_update_weeks = @longTermUpdateWeeks,
+ email_from_name = @emailFromName,
+ email_from_address = @emailFromAddress,
+ fonts = @fonts,
+ heading_color = @headingColor,
+ line_color = @lineColor,
+ heading_font_size = @headingFontSize,
+ text_font_size = @textFontSize,
+ request_sort = @requestSort,
+ group_password = @groupPassword,
+ default_email_type = @defaultEmailType,
+ is_public = @isPublic,
+ time_zone_id = @timeZoneId,
+ page_size = @pageSize,
+ as_of_date_display = @asOfDateDisplay
+ WHERE small_group_id = @groupId"""
+ |> Sql.parameters
+ [ "@groupId", Sql.uuid pref.SmallGroupId.Value
+ "@daysToKeepNew", Sql.int pref.DaysToKeepNew
+ "@daysToExpire", Sql.int pref.DaysToExpire
+ "@longTermUpdateWeeks", Sql.int pref.LongTermUpdateWeeks
+ "@emailFromName", Sql.string pref.EmailFromName
+ "@emailFromAddress", Sql.string pref.EmailFromAddress
+ "@fonts", Sql.string pref.Fonts
+ "@headingColor", Sql.string pref.HeadingColor
+ "@lineColor", Sql.string pref.LineColor
+ "@headingFontSize", Sql.int pref.HeadingFontSize
+ "@textFontSize", Sql.int pref.TextFontSize
+ "@requestSort", Sql.string (RequestSort.toCode pref.RequestSort)
+ "@groupPassword", Sql.string pref.GroupPassword
+ "@defaultEmailType", Sql.string (EmailFormat.toCode pref.DefaultEmailType)
+ "@isPublic", Sql.bool pref.IsPublic
+ "@timeZoneId", Sql.string (TimeZoneId.toString pref.TimeZoneId)
+ "@pageSize", Sql.int pref.PageSize
+ "@asOfDateDisplay", Sql.string (AsOfDateDisplay.toCode pref.AsOfDateDisplay)
+ ]
+ |> Sql.executeNonQueryAsync
+ return ()
+ }
+
+ /// Get a small group by its ID
+ let tryById (groupId : SmallGroupId) conn = backgroundTask {
+ let! group =
+ Sql.existingConnection conn
+ |> Sql.query "SELECT * FROM pt.small_group WHERE id = @id"
+ |> Sql.parameters [ "@id", Sql.uuid groupId.Value ]
+ |> Sql.executeAsync mapToSmallGroup
+ return List.tryHead group
+ }
+
+ /// Get a small group by its ID with its list preferences populated
+ let tryByIdWithPreferences (groupId : SmallGroupId) conn = backgroundTask {
+ let! group =
+ Sql.existingConnection conn
+ |> Sql.query """
+ SELECT sg.*, lp.*
+ FROM pt.small_group sg
+ INNER JOIN pt.list_preference lp ON lp.small_group_id = sg.id
+ WHERE sg.id = @id"""
+ |> Sql.parameters [ "@id", Sql.uuid groupId.Value ]
+ |> Sql.executeAsync mapToSmallGroupWithPreferences
+ return List.tryHead group
+ }
+
+
+/// Functions to manipulate users
+module Users =
+
+ /// Retrieve all PrayerTracker users
+ let all conn =
+ Sql.existingConnection conn
+ |> Sql.query "SELECT * FROM pt.pt_user ORDER BY last_name, first_name"
+ |> Sql.executeAsync mapToUser
+
+ /// Count the number of users for a church
+ let countByChurch (churchId : ChurchId) conn =
+ Sql.existingConnection conn
+ |> Sql.query """
+ SELECT COUNT(u.id) AS user_count
+ FROM pt.pt_user u
+ WHERE EXISTS (
+ SELECT 1
+ FROM pt.user_small_group usg
+ INNER JOIN pt.small_group sg ON sg.id = usg.small_group_id
+ WHERE usg.user_id = u.id
+ AND sg.church_id = @churchId)"""
+ |> Sql.parameters [ "@churchId", Sql.uuid churchId.Value ]
+ |> Sql.executeRowAsync (fun row -> row.int "user_count")
+
+ /// Count the number of users for a small group
+ let countByGroup (groupId : SmallGroupId) conn =
+ Sql.existingConnection conn
+ |> Sql.query "SELECT COUNT(user_id) AS user_count FROM pt.user_small_group WHERE small_group_id = @groupId"
+ |> Sql.parameters [ "@groupId", Sql.uuid groupId.Value ]
+ |> Sql.executeRowAsync (fun row -> row.int "user_count")
+
+ /// Delete a user by its database ID
+ let deleteById (userId : UserId) conn = backgroundTask {
+ let! _ =
+ Sql.existingConnection conn
+ |> Sql.query "DELETE FROM pt.pt_user WHERE id = @id"
+ |> Sql.parameters [ "@id", Sql.uuid userId.Value ]
+ |> Sql.executeNonQueryAsync
+ return ()
+ }
+
+ /// Get the IDs of the small groups for which the given user is authorized
+ let groupIdsByUserId (userId : UserId) conn =
+ Sql.existingConnection conn
+ |> Sql.query "SELECT small_group_id FROM pt.user_small_group WHERE user_id = @id"
+ |> Sql.parameters [ "@id", Sql.uuid userId.Value ]
+ |> Sql.executeAsync (fun row -> SmallGroupId (row.uuid "small_group_id"))
+
+ /// Get a list of users authorized to administer the given small group
+ let listByGroupId (groupId : SmallGroupId) conn =
+ Sql.existingConnection conn
+ |> Sql.query """
+ SELECT u.*
+ FROM pt.pt_user u
+ INNER JOIN pt.user_small_group usg ON usg.user_id = u.id
+ WHERE usg.small_group_id = @groupId
+ ORDER BY u.last_name, u.first_name"""
+ |> Sql.parameters [ "@groupId", Sql.uuid groupId.Value ]
+ |> Sql.executeAsync mapToUser
+
+ /// Save a user's information
+ let save (user : User) conn = backgroundTask {
+ let! _ =
+ Sql.existingConnection conn
+ |> Sql.query """
+ INSERT INTO pt.pt_user (
+ id, first_name, last_name, email, is_admin, password_hash
+ ) VALUES (
+ @id, @firstName, @lastName, @email, @isAdmin, @passwordHash
+ ) ON CONFLICT (id) DO UPDATE
+ SET first_name = EXCLUDED.first_name,
+ last_name = EXCLUDED.last_name,
+ email = EXCLUDED.email,
+ is_admin = EXCLUDED.is_admin,
+ password_hash = EXCLUDED.password_hash"""
+ |> Sql.parameters
+ [ "@id", Sql.uuid user.Id.Value
+ "@firstName", Sql.string user.FirstName
+ "@lastName", Sql.string user.LastName
+ "@email", Sql.string user.Email
+ "@isAdmin", Sql.bool user.IsAdmin
+ "@passwordHash", Sql.string user.PasswordHash
+ ]
+ |> Sql.executeNonQueryAsync
+ return ()
+ }
+
+ /// Find a user by its e-mail address and authorized small group
+ let tryByEmailAndGroup email (groupId : SmallGroupId) conn = backgroundTask {
+ let! user =
+ Sql.existingConnection conn
+ |> Sql.query """
+ SELECT u.*
+ FROM pt.pt_user u
+ INNER JOIN pt.user_small_group usg ON usg.user_id = u.id AND usg.small_group_id = @groupId
+ WHERE u.email = @email"""
+ |> Sql.parameters [ "@email", Sql.string email; "@groupId", Sql.uuid groupId.Value ]
+ |> Sql.executeAsync mapToUser
+ return List.tryHead user
+ }
+
+ /// Find a user by their database ID
+ let tryById (userId : UserId) conn = backgroundTask {
+ let! user =
+ Sql.existingConnection conn
+ |> Sql.query "SELECT * FROM pt.pt_user WHERE id = @id"
+ |> Sql.parameters [ "@id", Sql.uuid userId.Value ]
+ |> Sql.executeAsync mapToUser
+ return List.tryHead user
+ }
+
+ /// Update a user's last seen date/time
+ let updateLastSeen (userId : UserId) (now : Instant) conn = backgroundTask {
+ let! _ =
+ Sql.existingConnection conn
+ |> Sql.query "UPDATE pt.pt_user SET last_seen = @now WHERE id = @id"
+ |> Sql.parameters [ "@id", Sql.uuid userId.Value; "@now", Sql.parameter (NpgsqlParameter ("@now", now)) ]
+ |> Sql.executeNonQueryAsync
+ return ()
+ }
+
+ /// Update a user's password hash
+ let updatePassword (user : User) conn = backgroundTask {
+ let! _ =
+ Sql.existingConnection conn
+ |> Sql.query "UPDATE pt.pt_user SET password_hash = @passwordHash WHERE id = @id"
+ |> Sql.parameters [ "@id", Sql.uuid user.Id.Value; "@passwordHash", Sql.string user.PasswordHash ]
+ |> Sql.executeNonQueryAsync
+ return ()
+ }
+
+ /// Update a user's authorized small groups
+ let updateSmallGroups (userId : UserId) groupIds conn = backgroundTask {
+ let! existingGroupIds = groupIdsByUserId userId conn
+ let toAdd =
+ groupIds |> List.filter (fun it -> existingGroupIds |> List.exists (fun grpId -> grpId = it) |> not)
+ let toDelete =
+ existingGroupIds |> List.filter (fun it -> groupIds |> List.exists (fun grpId -> grpId = it) |> not)
+ let queries = seq {
+ if not (List.isEmpty toAdd) then
+ "INSERT INTO pt.user_small_group VALUES (@userId, @smallGroupId)",
+ toAdd |> List.map (fun it -> [ "@userId", Sql.uuid userId.Value; "@smallGroupId", Sql.uuid it.Value ])
+ if not (List.isEmpty toDelete) then
+ "DELETE FROM pt.user_small_group WHERE user_id = @userId AND small_group_id = @smallGroupId",
+ toDelete
+ |> List.map (fun it -> [ "@userId", Sql.uuid userId.Value; "@smallGroupId", Sql.uuid it.Value ])
+ }
+ if not (Seq.isEmpty queries) then
+ let! _ =
+ Sql.existingConnection conn
+ |> Sql.executeTransactionAsync (List.ofSeq queries)
+ ()
+ }
diff --git a/src/PrayerTracker.Data/AppDbContext.fs b/src/PrayerTracker.Data/AppDbContext.fs
deleted file mode 100644
index c4199c2..0000000
--- a/src/PrayerTracker.Data/AppDbContext.fs
+++ /dev/null
@@ -1,86 +0,0 @@
-namespace PrayerTracker
-
-open Microsoft.EntityFrameworkCore
-open PrayerTracker.Entities
-
-/// EF Core data context for PrayerTracker
-[]
-type AppDbContext (options : DbContextOptions) =
- inherit DbContext (options)
-
- []
- val mutable private churches : DbSet
- []
- val mutable private members : DbSet
- []
- val mutable private prayerRequests : DbSet
- []
- val mutable private preferences : DbSet
- []
- val mutable private smallGroups : DbSet
- []
- val mutable private timeZones : DbSet
- []
- val mutable private users : DbSet
- []
- val mutable private userGroupXref : DbSet
-
- /// Churches
- member this.Churches
- with get() = this.churches
- and set v = this.churches <- v
-
- /// Small group members
- member this.Members
- with get() = this.members
- and set v = this.members <- v
-
- /// Prayer requests
- member this.PrayerRequests
- with get() = this.prayerRequests
- and set v = this.prayerRequests <- v
-
- /// Request list preferences (by class)
- member this.Preferences
- with get() = this.preferences
- and set v = this.preferences <- v
-
- /// Small groups
- member this.SmallGroups
- with get() = this.smallGroups
- and set v = this.smallGroups <- v
-
- /// Time zones
- member this.TimeZones
- with get() = this.timeZones
- and set v = this.timeZones <- v
-
- /// Users
- member this.Users
- with get() = this.users
- and set v = this.users <- v
-
- /// User / small group cross-reference
- member this.UserGroupXref
- with get() = this.userGroupXref
- and set v = this.userGroupXref <- v
-
- /// F#-style async for saving changes
- member this.AsyncSaveChanges () =
- this.SaveChangesAsync () |> Async.AwaitTask
-
- override __.OnModelCreating (modelBuilder : ModelBuilder) =
- base.OnModelCreating modelBuilder
-
- modelBuilder.HasDefaultSchema "pt" |> ignore
-
- [ Church.configureEF
- ListPreferences.configureEF
- Member.configureEF
- PrayerRequest.configureEF
- SmallGroup.configureEF
- TimeZone.configureEF
- User.configureEF
- UserSmallGroup.configureEF
- ]
- |> List.iter (fun x -> x modelBuilder)
diff --git a/src/PrayerTracker.Data/DataAccess.fs b/src/PrayerTracker.Data/DataAccess.fs
deleted file mode 100644
index c8bf97f..0000000
--- a/src/PrayerTracker.Data/DataAccess.fs
+++ /dev/null
@@ -1,373 +0,0 @@
-[]
-module PrayerTracker.DataAccess
-
-open Microsoft.EntityFrameworkCore
-open PrayerTracker.Entities
-open System.Collections.Generic
-open System.Linq
-
-[]
-module private Helpers =
-
- open Microsoft.FSharpLu
- open System.Threading.Tasks
-
- /// Central place to append sort criteria for prayer request queries
- let reqSort sort (q : IQueryable) =
- match sort with
- | SortByDate ->
- query {
- for req in q do
- sortByDescending req.updatedDate
- thenByDescending req.enteredDate
- thenBy req.requestor
- }
- | SortByRequestor ->
- query {
- for req in q do
- sortBy req.requestor
- thenByDescending req.updatedDate
- thenByDescending req.enteredDate
- }
-
- /// Convert a possibly-null object to an option, wrapped as a task
- let toOptionTask<'T> (item : 'T) = (Option.fromObject >> Task.FromResult) item
-
-
-type AppDbContext with
-
- (*-- DISCONNECTED DATA EXTENSIONS --*)
-
- /// Add an entity entry to the tracked data context with the status of Added
- member this.AddEntry<'TEntity when 'TEntity : not struct> (e : 'TEntity) =
- this.Entry<'TEntity>(e).State <- EntityState.Added
-
- /// Add an entity entry to the tracked data context with the status of Updated
- member this.UpdateEntry<'TEntity when 'TEntity : not struct> (e : 'TEntity) =
- this.Entry<'TEntity>(e).State <- EntityState.Modified
-
- /// Add an entity entry to the tracked data context with the status of Deleted
- member this.RemoveEntry<'TEntity when 'TEntity : not struct> (e : 'TEntity) =
- this.Entry<'TEntity>(e).State <- EntityState.Deleted
-
- (*-- CHURCH EXTENSIONS --*)
-
- /// Find a church by its Id
- member this.TryChurchById cId =
- query {
- for ch in this.Churches.AsNoTracking () do
- where (ch.churchId = cId)
- exactlyOneOrDefault
- }
- |> toOptionTask
-
- /// Find all churches
- member this.AllChurches () =
- task {
- let q =
- query {
- for ch in this.Churches.AsNoTracking () do
- sortBy ch.name
- }
- let! churches = q.ToListAsync ()
- return List.ofSeq churches
- }
-
- (*-- MEMBER EXTENSIONS --*)
-
- /// Get a small group member by its Id
- member this.TryMemberById mId =
- query {
- for mbr in this.Members.AsNoTracking () do
- where (mbr.memberId = mId)
- select mbr
- exactlyOneOrDefault
- }
- |> toOptionTask
-
- /// Find all members for a small group
- member this.AllMembersForSmallGroup gId =
- task {
- let q =
- query {
- for mbr in this.Members.AsNoTracking () do
- where (mbr.smallGroupId = gId)
- sortBy mbr.memberName
- }
- let! mbrs = q.ToListAsync ()
- return List.ofSeq mbrs
- }
-
- /// Count members for a small group
- member this.CountMembersForSmallGroup gId =
- this.Members.CountAsync (fun m -> m.smallGroupId = gId)
-
- (*-- PRAYER REQUEST EXTENSIONS --*)
-
- /// Get a prayer request by its Id
- member this.TryRequestById reqId =
- query {
- for req in this.PrayerRequests.AsNoTracking () do
- where (req.prayerRequestId = reqId)
- exactlyOneOrDefault
- }
- |> toOptionTask
-
- /// Get all (or active) requests for a small group as of now or the specified date
- // TODO: why not make this an async list like the rest of these methods?
- member this.AllRequestsForSmallGroup (grp : SmallGroup) clock listDate activeOnly pageNbr : PrayerRequest seq =
- let theDate = match listDate with Some dt -> dt | _ -> grp.localDateNow clock
- query {
- for req in this.PrayerRequests.AsNoTracking () do
- where (req.smallGroupId = grp.smallGroupId)
- }
- |> function
- | q when activeOnly ->
- let asOf = theDate.AddDays(-(float grp.preferences.daysToExpire)).Date
- query {
- for req in q do
- where ( ( req.updatedDate > asOf
- || req.expiration = Manual
- || req.requestType = LongTermRequest
- || req.requestType = Expecting)
- && req.expiration <> Forced)
- }
- | q -> q
- |> reqSort grp.preferences.requestSort
- |> function
- | q ->
- match activeOnly with
- | true -> upcast q
- | false ->
- upcast query {
- for req in q do
- skip ((pageNbr - 1) * grp.preferences.pageSize)
- take grp.preferences.pageSize
- }
-
- /// Count prayer requests for the given small group Id
- member this.CountRequestsBySmallGroup gId =
- this.PrayerRequests.CountAsync (fun pr -> pr.smallGroupId = gId)
-
- /// Count prayer requests for the given church Id
- member this.CountRequestsByChurch cId =
- this.PrayerRequests.CountAsync (fun pr -> pr.smallGroup.churchId = cId)
-
- /// Get all (or active) requests for a small group as of now or the specified date
- // TODO: same as above...
- member this.SearchRequestsForSmallGroup (grp : SmallGroup) (searchTerm : string) pageNbr : PrayerRequest seq =
- let pgSz = grp.preferences.pageSize
- let toSkip = (pageNbr - 1) * pgSz
- let sql =
- """ SELECT * FROM pt."PrayerRequest" WHERE "SmallGroupId" = {0} AND "Text" ILIKE {1}
- UNION
- SELECT * FROM pt."PrayerRequest" WHERE "SmallGroupId" = {0} AND COALESCE("Requestor", '') ILIKE {1}"""
- let like = sprintf "%%%s%%"
- this.PrayerRequests.FromSqlRaw(sql, grp.smallGroupId, like searchTerm).AsNoTracking ()
- |> reqSort grp.preferences.requestSort
- |> function
- | q ->
- upcast query {
- for req in q do
- skip toSkip
- take pgSz
- }
-
- (*-- SMALL GROUP EXTENSIONS --*)
-
- /// Find a small group by its Id
- member this.TryGroupById gId =
- query {
- for grp in this.SmallGroups.AsNoTracking().Include (fun sg -> sg.preferences) do
- where (grp.smallGroupId = gId)
- exactlyOneOrDefault
- }
- |> toOptionTask
-
- /// Get small groups that are public or password protected
- member this.PublicAndProtectedGroups () =
- task {
- let smallGroups = this.SmallGroups.AsNoTracking().Include(fun sg -> sg.preferences).Include (fun sg -> sg.church)
- let q =
- query {
- for grp in smallGroups do
- where ( grp.preferences.isPublic
- || (grp.preferences.groupPassword <> null && grp.preferences.groupPassword <> ""))
- sortBy grp.church.name
- thenBy grp.name
- }
- let! grps = q.ToListAsync ()
- return List.ofSeq grps
- }
-
- /// Get small groups that are password protected
- member this.ProtectedGroups () =
- task {
- let q =
- query {
- for grp in this.SmallGroups.AsNoTracking().Include (fun sg -> sg.church) do
- where (grp.preferences.groupPassword <> null && grp.preferences.groupPassword <> "")
- sortBy grp.church.name
- thenBy grp.name
- }
- let! grps = q.ToListAsync ()
- return List.ofSeq grps
- }
-
- /// Get all small groups
- member this.AllGroups () =
- task {
- let! grps =
- this.SmallGroups.AsNoTracking()
- .Include(fun sg -> sg.church)
- .Include(fun sg -> sg.preferences)
- .Include(fun sg -> sg.preferences.timeZone)
- .OrderBy(fun sg -> sg.name)
- .ToListAsync ()
- return List.ofSeq grps
- }
-
- /// Get a small group list by their Id, with their church prepended to their name
- member this.GroupList () =
- task {
- let q =
- query {
- for grp in this.SmallGroups.AsNoTracking().Include (fun sg -> sg.church) do
- sortBy grp.church.name
- thenBy grp.name
- }
- let! grps = q.ToListAsync ()
- return grps
- |> Seq.map (fun grp -> grp.smallGroupId.ToString "N", $"{grp.church.name} | {grp.name}")
- |> List.ofSeq
- }
-
- /// Log on a small group
- member this.TryGroupLogOnByPassword gId pw =
- task {
- match! this.TryGroupById gId with
- | None -> return None
- | Some grp ->
- match pw = grp.preferences.groupPassword with
- | true -> return Some grp
- | _ -> return None
- }
-
- /// Check a cookie log on for a small group
- member this.TryGroupLogOnByCookie gId pwHash (hasher : string -> string) =
- task {
- match! this.TryGroupById gId with
- | None -> return None
- | Some grp ->
- match pwHash = hasher grp.preferences.groupPassword with
- | true -> return Some grp
- | _ -> return None
- }
-
- /// Count small groups for the given church Id
- member this.CountGroupsByChurch cId =
- this.SmallGroups.CountAsync (fun sg -> sg.churchId = cId)
-
- (*-- TIME ZONE EXTENSIONS --*)
-
- /// Get a time zone by its Id
- member this.TryTimeZoneById tzId =
- query {
- for tz in this.TimeZones do
- where (tz.timeZoneId = tzId)
- exactlyOneOrDefault
- }
- |> toOptionTask
-
- /// Get all time zones
- member this.AllTimeZones () =
- task {
- let q =
- query {
- for tz in this.TimeZones do
- sortBy tz.sortOrder
- }
- let! tzs = q.ToListAsync ()
- return List.ofSeq tzs
- }
-
- (*-- USER EXTENSIONS --*)
-
- /// Find a user by its Id
- member this.TryUserById uId =
- query {
- for usr in this.Users.AsNoTracking () do
- where (usr.userId = uId)
- exactlyOneOrDefault
- }
- |> toOptionTask
-
- /// Find a user by its e-mail address and authorized small group
- member this.TryUserByEmailAndGroup email gId =
- query {
- for usr in this.Users.AsNoTracking () do
- where (usr.emailAddress = email && usr.smallGroups.Any (fun xref -> xref.smallGroupId = gId))
- exactlyOneOrDefault
- }
- |> toOptionTask
-
- /// Find a user by its Id (tracked entity), eagerly loading the user's groups
- member this.TryUserByIdWithGroups uId =
- query {
- for usr in this.Users.AsNoTracking().Include (fun u -> u.smallGroups) do
- where (usr.userId = uId)
- exactlyOneOrDefault
- }
- |> toOptionTask
-
- /// Get a list of all users
- member this.AllUsers () =
- task {
- let q =
- query {
- for usr in this.Users.AsNoTracking () do
- sortBy usr.lastName
- thenBy usr.firstName
- }
- let! usrs = q.ToListAsync ()
- return List.ofSeq usrs
- }
-
- /// Get all PrayerTracker users as members (used to send e-mails)
- member this.AllUsersAsMembers () =
- task {
- let! users = this.AllUsers ()
- return users |> List.map (fun u -> { Member.empty with email = u.emailAddress; memberName = u.fullName })
- }
-
- /// Find a user based on their credentials
- member this.TryUserLogOnByPassword email pwHash gId =
- query {
- for usr in this.Users.AsNoTracking () do
- where ( usr.emailAddress = email
- && usr.passwordHash = pwHash
- && usr.smallGroups.Any (fun xref -> xref.smallGroupId = gId))
- exactlyOneOrDefault
- }
- |> toOptionTask
-
- /// Find a user based on credentials stored in a cookie
- member this.TryUserLogOnByCookie uId gId pwHash =
- task {
- match! this.TryUserByIdWithGroups uId with
- | None -> return None
- | Some usr ->
- match pwHash = usr.passwordHash && usr.smallGroups |> Seq.exists (fun xref -> xref.smallGroupId = gId) with
- | true ->
- this.Entry(usr).State <- EntityState.Detached
- return Some { usr with passwordHash = ""; salt = None; smallGroups = List() }
- | _ -> return None
- }
-
- /// Count the number of users for a small group
- member this.CountUsersBySmallGroup gId =
- this.Users.CountAsync (fun u -> u.smallGroups.Any (fun xref -> xref.smallGroupId = gId))
-
- /// Count the number of users for a church
- member this.CountUsersByChurch cId =
- this.Users.CountAsync (fun u -> u.smallGroups.Any (fun xref -> xref.smallGroup.churchId = cId))
diff --git a/src/PrayerTracker.Data/DistributedCache.fs b/src/PrayerTracker.Data/DistributedCache.fs
new file mode 100644
index 0000000..8abf8c8
--- /dev/null
+++ b/src/PrayerTracker.Data/DistributedCache.fs
@@ -0,0 +1,218 @@
+namespace PrayerTracker.Data
+
+open System.Threading
+open System.Threading.Tasks
+open Microsoft.Extensions.Caching.Distributed
+open NodaTime
+open Npgsql
+open Npgsql.FSharp
+
+/// Helper types and functions for the cache
+[]
+module private CacheHelpers =
+
+ open System
+
+ /// The cache entry
+ type Entry =
+ { /// The ID of the cache entry
+ Id : string
+
+ /// The value to be cached
+ Payload : byte[]
+
+ /// When this entry will expire
+ ExpireAt : Instant
+
+ /// The duration by which the expiration should be pushed out when being refreshed
+ SlidingExpiration : Duration option
+
+ /// The must-expire-by date/time for the cache entry
+ AbsoluteExpiration : Instant option
+ }
+
+ /// Run a task synchronously
+ let sync<'T> (it : Task<'T>) = it |> (Async.AwaitTask >> Async.RunSynchronously)
+
+ /// Get the current instant
+ let getNow () = SystemClock.Instance.GetCurrentInstant ()
+
+ /// Create a parameter for the expire-at time
+ let expireParam (it : Instant) =
+ "@expireAt", Sql.parameter (NpgsqlParameter ("@expireAt", it))
+
+ /// Create a parameter for a possibly-missing NodaTime type
+ let optParam<'T> name (it : 'T option) =
+ let p = NpgsqlParameter ($"@%s{name}", if Option.isSome it then box it.Value else DBNull.Value)
+ p.ParameterName, Sql.parameter p
+
+
+/// A distributed cache implementation in PostgreSQL used to handle sessions for myWebLog
+type DistributedCache (connStr : string) =
+
+ // ~~~ INITIALIZATION ~~~
+
+ do
+ task {
+ let! exists =
+ Sql.connect connStr
+ |> Sql.query $"
+ SELECT EXISTS
+ (SELECT 1 FROM pg_tables WHERE schemaname = 'public' AND tablename = 'session')
+ AS does_exist"
+ |> Sql.executeRowAsync (fun row -> row.bool "does_exist")
+ if not exists then
+ let! _ =
+ Sql.connect connStr
+ |> Sql.query
+ "CREATE TABLE session (
+ id TEXT NOT NULL PRIMARY KEY,
+ payload BYTEA NOT NULL,
+ expire_at TIMESTAMPTZ NOT NULL,
+ sliding_expiration INTERVAL,
+ absolute_expiration TIMESTAMPTZ);
+ CREATE INDEX idx_session_expiration ON session (expire_at)"
+ |> Sql.executeNonQueryAsync
+ ()
+ } |> sync
+
+ // ~~~ SUPPORT FUNCTIONS ~~~
+
+ /// Get an entry, updating it for sliding expiration
+ let getEntry key = backgroundTask {
+ let idParam = "@id", Sql.string key
+ let! tryEntry =
+ Sql.connect connStr
+ |> Sql.query "SELECT * FROM session WHERE id = @id"
+ |> Sql.parameters [ idParam ]
+ |> Sql.executeAsync (fun row ->
+ { Id = row.string "id"
+ Payload = row.bytea "payload"
+ ExpireAt = row.fieldValue "expire_at"
+ SlidingExpiration = row.fieldValueOrNone "sliding_expiration"
+ AbsoluteExpiration = row.fieldValueOrNone "absolute_expiration" })
+ match List.tryHead tryEntry with
+ | Some entry ->
+ let now = getNow ()
+ let slideExp = defaultArg entry.SlidingExpiration Duration.MinValue
+ let absExp = defaultArg entry.AbsoluteExpiration Instant.MinValue
+ let needsRefresh, item =
+ if entry.ExpireAt = absExp then false, entry
+ elif slideExp = Duration.MinValue && absExp = Instant.MinValue then false, entry
+ elif absExp > Instant.MinValue && entry.ExpireAt.Plus slideExp > absExp then
+ true, { entry with ExpireAt = absExp }
+ else true, { entry with ExpireAt = now.Plus slideExp }
+ if needsRefresh then
+ let! _ =
+ Sql.connect connStr
+ |> Sql.query "UPDATE session SET expire_at = @expireAt WHERE id = @id"
+ |> Sql.parameters [ expireParam item.ExpireAt; idParam ]
+ |> Sql.executeNonQueryAsync
+ ()
+ return if item.ExpireAt > now then Some entry else None
+ | None -> return None
+ }
+
+ /// The last time expired entries were purged (runs every 30 minutes)
+ let mutable lastPurge = Instant.MinValue
+
+ /// Purge expired entries every 30 minutes
+ let purge () = backgroundTask {
+ let now = getNow ()
+ if lastPurge.Plus (Duration.FromMinutes 30L) < now then
+ let! _ =
+ Sql.connect connStr
+ |> Sql.query "DELETE FROM session WHERE expire_at < @expireAt"
+ |> Sql.parameters [ expireParam now ]
+ |> Sql.executeNonQueryAsync
+ lastPurge <- now
+ }
+
+ /// Remove a cache entry
+ let removeEntry key = backgroundTask {
+ let! _ =
+ Sql.connect connStr
+ |> Sql.query "DELETE FROM session WHERE id = @id"
+ |> Sql.parameters [ "@id", Sql.string key ]
+ |> Sql.executeNonQueryAsync
+ ()
+ }
+
+ /// Save an entry
+ let saveEntry (opts : DistributedCacheEntryOptions) key payload = backgroundTask {
+ let now = getNow ()
+ let expireAt, slideExp, absExp =
+ if opts.SlidingExpiration.HasValue then
+ let slide = Duration.FromTimeSpan opts.SlidingExpiration.Value
+ now.Plus slide, Some slide, None
+ elif opts.AbsoluteExpiration.HasValue then
+ let exp = Instant.FromDateTimeOffset opts.AbsoluteExpiration.Value
+ exp, None, Some exp
+ elif opts.AbsoluteExpirationRelativeToNow.HasValue then
+ let exp = now.Plus (Duration.FromTimeSpan opts.AbsoluteExpirationRelativeToNow.Value)
+ exp, None, Some exp
+ else
+ // Default to 2 hour sliding expiration
+ let slide = Duration.FromHours 2
+ now.Plus slide, Some slide, None
+ let! _ =
+ Sql.connect connStr
+ |> Sql.query
+ "INSERT INTO session (
+ id, payload, expire_at, sliding_expiration, absolute_expiration
+ ) VALUES (
+ @id, @payload, @expireAt, @slideExp, @absExp
+ ) ON CONFLICT (id) DO UPDATE
+ SET payload = EXCLUDED.payload,
+ expire_at = EXCLUDED.expire_at,
+ sliding_expiration = EXCLUDED.sliding_expiration,
+ absolute_expiration = EXCLUDED.absolute_expiration"
+ |> Sql.parameters
+ [ "@id", Sql.string key
+ "@payload", Sql.bytea payload
+ expireParam expireAt
+ optParam "slideExp" slideExp
+ optParam "absExp" absExp ]
+ |> Sql.executeNonQueryAsync
+ ()
+ }
+
+ // ~~~ IMPLEMENTATION FUNCTIONS ~~~
+
+ /// Retrieve the data for a cache entry
+ let get key (_ : CancellationToken) = backgroundTask {
+ match! getEntry key with
+ | Some entry ->
+ do! purge ()
+ return entry.Payload
+ | None -> return null
+ }
+
+ /// Refresh an entry
+ let refresh key (cancelToken : CancellationToken) = backgroundTask {
+ let! _ = get key cancelToken
+ ()
+ }
+
+ /// Remove an entry
+ let remove key (_ : CancellationToken) = backgroundTask {
+ do! removeEntry key
+ do! purge ()
+ }
+
+ /// Set an entry
+ let set key value options (_ : CancellationToken) = backgroundTask {
+ do! saveEntry options key value
+ do! purge ()
+ }
+
+ interface IDistributedCache with
+ member this.Get key = get key CancellationToken.None |> sync
+ member this.GetAsync (key, token) = get key token
+ member this.Refresh key = refresh key CancellationToken.None |> sync
+ member this.RefreshAsync (key, token) = refresh key token
+ member this.Remove key = remove key CancellationToken.None |> sync
+ member this.RemoveAsync (key, token) = remove key token
+ member this.Set (key, value, options) = set key value options CancellationToken.None |> sync
+ member this.SetAsync (key, value, options, token) = set key value options token
+
diff --git a/src/PrayerTracker.Data/Entities.fs b/src/PrayerTracker.Data/Entities.fs
index 1780d11..29bcfd1 100644
--- a/src/PrayerTracker.Data/Entities.fs
+++ b/src/PrayerTracker.Data/Entities.fs
@@ -1,758 +1,557 @@
namespace PrayerTracker.Entities
-open FSharp.EFCore.OptionConverter
-open Microsoft.EntityFrameworkCore
-open NodaTime
-open System
-open System.Collections.Generic
-
-// fsharplint:disable RecordFieldNames MemberNames
-
(*-- SUPPORT TYPES --*)
/// How as-of dates should (or should not) be displayed with requests
type AsOfDateDisplay =
- /// No as-of date should be displayed
- | NoDisplay
- /// The as-of date should be displayed in the culture's short date format
- | ShortDate
- /// The as-of date should be displayed in the culture's long date format
- | LongDate
-with
- /// Convert to a DU case from a single-character string
- static member fromCode code =
- match code with
- | "N" -> NoDisplay
- | "S" -> ShortDate
- | "L" -> LongDate
- | _ -> invalidArg "code" (sprintf "Unknown code %s" code)
- /// Convert this DU case to a single-character string
- member this.code =
- match this with
- | NoDisplay -> "N"
- | ShortDate -> "S"
- | LongDate -> "L"
+ /// No as-of date should be displayed
+ | NoDisplay
+ /// The as-of date should be displayed in the culture's short date format
+ | ShortDate
+ /// The as-of date should be displayed in the culture's long date format
+ | LongDate
+
+/// Functions to support as-of date display options
+module AsOfDateDisplay =
+
+ /// Convert to a DU case from a single-character string
+ let fromCode code =
+ match code with
+ | "N" -> NoDisplay
+ | "S" -> ShortDate
+ | "L" -> LongDate
+ | _ -> invalidArg "code" $"Unknown code {code}"
+
+ /// Convert this DU case to a single-character string
+ let toCode = function NoDisplay -> "N" | ShortDate -> "S" | LongDate -> "L"
/// Acceptable e-mail formats
type EmailFormat =
- /// HTML e-mail
- | HtmlFormat
- /// Plain-text e-mail
- | PlainTextFormat
-with
- /// Convert to a DU case from a single-character string
- static member fromCode code =
- match code with
- | "H" -> HtmlFormat
- | "P" -> PlainTextFormat
- | _ -> invalidArg "code" (sprintf "Unknown code %s" code)
- /// Convert this DU case to a single-character string
- member this.code =
- match this with
- | HtmlFormat -> "H"
- | PlainTextFormat -> "P"
+ /// HTML e-mail
+ | HtmlFormat
+ /// Plain-text e-mail
+ | PlainTextFormat
+
+/// Functions to support e-mail formats
+module EmailFormat =
+
+ /// Convert to a DU case from a single-character string
+ let fromCode code =
+ match code with
+ | "H" -> HtmlFormat
+ | "P" -> PlainTextFormat
+ | _ -> invalidArg "code" $"Unknown code {code}"
+
+ /// Convert this DU case to a single-character string
+ let toCode = function HtmlFormat -> "H" | PlainTextFormat -> "P"
/// Expiration for requests
type Expiration =
- /// Follow the rules for normal expiration
- | Automatic
- /// Do not expire via rules
- | Manual
- /// Force immediate expiration
- | Forced
-with
- /// Convert to a DU case from a single-character string
- static member fromCode code =
- match code with
- | "A" -> Automatic
- | "M" -> Manual
- | "F" -> Forced
- | _ -> invalidArg "code" (sprintf "Unknown code %s" code)
- /// Convert this DU case to a single-character string
- member this.code =
- match this with
- | Automatic -> "A"
- | Manual -> "M"
- | Forced -> "F"
+ /// Follow the rules for normal expiration
+ | Automatic
+ /// Do not expire via rules
+ | Manual
+ /// Force immediate expiration
+ | Forced
+
+/// Functions to support expirations
+module Expiration =
+
+ /// Convert to a DU case from a single-character string
+ let fromCode code =
+ match code with
+ | "A" -> Automatic
+ | "M" -> Manual
+ | "F" -> Forced
+ | _ -> invalidArg "code" $"Unknown code {code}"
+
+ /// Convert this DU case to a single-character string
+ let toCode = function Automatic -> "A" | Manual -> "M" | Forced -> "F"
/// Types of prayer requests
type PrayerRequestType =
- /// Current requests
- | CurrentRequest
- /// Long-term/ongoing request
- | LongTermRequest
- /// Expectant couples
- | Expecting
- /// Praise reports
- | PraiseReport
- /// Announcements
- | Announcement
-with
- /// Convert to a DU case from a single-character string
- static member fromCode code =
- match code with
- | "C" -> CurrentRequest
- | "L" -> LongTermRequest
- | "E" -> Expecting
- | "P" -> PraiseReport
- | "A" -> Announcement
- | _ -> invalidArg "code" (sprintf "Unknown code %s" code)
- /// Convert this DU case to a single-character string
- member this.code =
- match this with
- | CurrentRequest -> "C"
- | LongTermRequest -> "L"
- | Expecting -> "E"
- | PraiseReport -> "P"
- | Announcement -> "A"
+ /// Current requests
+ | CurrentRequest
+ /// Long-term/ongoing request
+ | LongTermRequest
+ /// Expectant couples
+ | Expecting
+ /// Praise reports
+ | PraiseReport
+ /// Announcements
+ | Announcement
+
+/// Functions to support prayer request types
+module PrayerRequestType =
+
+ /// Convert to a DU case from a single-character string
+ let fromCode code =
+ match code with
+ | "C" -> CurrentRequest
+ | "L" -> LongTermRequest
+ | "E" -> Expecting
+ | "P" -> PraiseReport
+ | "A" -> Announcement
+ | _ -> invalidArg "code" $"Unknown code {code}"
+
+ /// Convert this DU case to a single-character string
+ let toCode =
+ function
+ | CurrentRequest -> "C"
+ | LongTermRequest -> "L"
+ | Expecting -> "E"
+ | PraiseReport -> "P"
+ | Announcement -> "A"
/// How requests should be sorted
type RequestSort =
- /// Sort by date, then by requestor/subject
- | SortByDate
- /// Sort by requestor/subject, then by date
- | SortByRequestor
+ /// Sort by date, then by requestor/subject
+ | SortByDate
+ /// Sort by requestor/subject, then by date
+ | SortByRequestor
+
+/// Functions to support request sorts
+module RequestSort =
+
+ /// Convert to a DU case from a single-character string
+ let fromCode code =
+ match code with
+ | "D" -> SortByDate
+ | "R" -> SortByRequestor
+ | _ -> invalidArg "code" $"Unknown code {code}"
+
+ /// Convert this DU case to a single-character string
+ let toCode = function SortByDate -> "D" | SortByRequestor -> "R"
+
+
+open System
+
+/// PK type for the Church entity
+type ChurchId =
+ | ChurchId of Guid
with
- /// Convert to a DU case from a single-character string
- static member fromCode code =
- match code with
- | "D" -> SortByDate
- | "R" -> SortByRequestor
- | _ -> invalidArg "code" (sprintf "Unknown code %s" code)
- /// Convert this DU case to a single-character string
- member this.code =
- match this with
- | SortByDate -> "D"
- | SortByRequestor -> "R"
+ /// The GUID value of the church ID
+ member this.Value = this |> function ChurchId guid -> guid
-module Converters =
- open Microsoft.EntityFrameworkCore.Storage.ValueConversion
- open Microsoft.FSharp.Linq.RuntimeHelpers
- open System.Linq.Expressions
+/// PK type for the Member entity
+type MemberId =
+ | MemberId of Guid
+with
+ /// The GUID value of the member ID
+ member this.Value = this |> function MemberId guid -> guid
- let private asOfFromDU =
- <@ Func(fun (x : AsOfDateDisplay) -> x.code) @>
- |> LeafExpressionConverter.QuotationToExpression
- |> unbox>>
- let private asOfToDU =
- <@ Func(AsOfDateDisplay.fromCode) @>
- |> LeafExpressionConverter.QuotationToExpression
- |> unbox>>
-
- let private emailFromDU =
- <@ Func(fun (x : EmailFormat) -> x.code) @>
- |> LeafExpressionConverter.QuotationToExpression
- |> unbox>>
+/// PK type for the PrayerRequest entity
+type PrayerRequestId =
+ | PrayerRequestId of Guid
+with
+ /// The GUID value of the prayer request ID
+ member this.Value = this |> function PrayerRequestId guid -> guid
- let private emailToDU =
- <@ Func(EmailFormat.fromCode) @>
- |> LeafExpressionConverter.QuotationToExpression
- |> unbox>>
-
- let private expFromDU =
- <@ Func(fun (x : Expiration) -> x.code) @>
- |> LeafExpressionConverter.QuotationToExpression
- |> unbox>>
- let private expToDU =
- <@ Func(Expiration.fromCode) @>
- |> LeafExpressionConverter.QuotationToExpression
- |> unbox>>
-
- let private sortFromDU =
- <@ Func(fun (x : RequestSort) -> x.code) @>
- |> LeafExpressionConverter.QuotationToExpression
- |> unbox>>
+/// PK type for the SmallGroup entity
+type SmallGroupId =
+ | SmallGroupId of Guid
+with
+ /// The GUID value of the small group ID
+ member this.Value = this |> function SmallGroupId guid -> guid
- let private sortToDU =
- <@ Func(RequestSort.fromCode) @>
- |> LeafExpressionConverter.QuotationToExpression
- |> unbox>>
-
- let private typFromDU =
- <@ Func(fun (x : PrayerRequestType) -> x.code) @>
- |> LeafExpressionConverter.QuotationToExpression
- |> unbox>>
- let private typToDU =
- <@ Func(PrayerRequestType.fromCode) @>
- |> LeafExpressionConverter.QuotationToExpression
- |> unbox>>
-
- /// Conversion between a string and an AsOfDateDisplay DU value
- type AsOfDateDisplayConverter () =
- inherit ValueConverter (asOfFromDU, asOfToDU)
+/// PK type for the TimeZone entity
+type TimeZoneId = TimeZoneId of string
- /// Conversion between a string and an EmailFormat DU value
- type EmailFormatConverter () =
- inherit ValueConverter (emailFromDU, emailToDU)
+/// Functions to support time zone IDs
+module TimeZoneId =
+
+ /// Convert a time zone ID to its string value
+ let toString = function TimeZoneId it -> it
- /// Conversion between a string and an Expiration DU value
- type ExpirationConverter () =
- inherit ValueConverter (expFromDU, expToDU)
- /// Conversion between a string and an AsOfDateDisplay DU value
- type PrayerRequestTypeConverter () =
- inherit ValueConverter (typFromDU, typToDU)
-
- /// Conversion between a string and a RequestSort DU value
- type RequestSortConverter () =
- inherit ValueConverter (sortFromDU, sortToDU)
+/// PK type for the User entity
+type UserId =
+ | UserId of Guid
+with
+ /// The GUID value of the user ID
+ member this.Value = this |> function UserId guid -> guid
+(*-- SPECIFIC VIEW TYPES --*)
/// Statistics for churches
[]
type ChurchStats =
- { /// The number of small groups in the church
- smallGroups : int
- /// The number of prayer requests in the church
- prayerRequests : int
- /// The number of users who can access small groups in the church
- users : int
+ { /// The number of small groups in the church
+ SmallGroups : int
+
+ /// The number of prayer requests in the church
+ PrayerRequests : int
+
+ /// The number of users who can access small groups in the church
+ Users : int
}
-/// PK type for the Church entity
-type ChurchId = Guid
-/// PK type for the Member entity
-type MemberId = Guid
-
-/// PK type for the PrayerRequest entity
-type PrayerRequestId = Guid
-
-/// PK type for the SmallGroup entity
-type SmallGroupId = Guid
-
-/// PK type for the TimeZone entity
-type TimeZoneId = string
-
-/// PK type for the User entity
-type UserId = Guid
-
-/// PK for User/SmallGroup cross-reference table
-type UserSmallGroupKey =
- { userId : UserId
- smallGroupId : SmallGroupId
- }
+/// Information needed to display the public/protected request list and small group maintenance pages
+[]
+type SmallGroupInfo =
+ { /// The ID of the small group
+ Id : string
+
+ /// The name of the small group
+ Name : string
+
+ /// The name of the church to which the small group belongs
+ ChurchName : string
+
+ /// The ID of the time zone for the small group
+ TimeZoneId : TimeZoneId
+
+ /// Whether the small group has a publicly-available request list
+ IsPublic : bool
+ }
(*-- ENTITIES --*)
+open NodaTime
+
/// This represents a church
-type [] Church =
- { /// The Id of this church
- churchId : ChurchId
- /// The name of the church
- name : string
- /// The city where the church is
- city : string
- /// The state where the church is
- st : string
- /// Does this church have an active interface with Virtual Prayer Room?
- hasInterface : bool
- /// The address for the interface
- interfaceAddress : string option
-
- /// Small groups for this church
- smallGroups : ICollection
+[]
+type Church =
+ { /// The ID of this church
+ Id : ChurchId
+
+ /// The name of the church
+ Name : string
+
+ /// The city where the church is
+ City : string
+
+ /// The 2-letter state or province code for the church's location
+ State : string
+
+ /// Does this church have an active interface with Virtual Prayer Space?
+ HasVpsInterface : bool
+
+ /// The address for the interface
+ InterfaceAddress : string option
}
- with
+
+/// Functions to support churches
+module Church =
+
/// An empty church
// aww... how sad :(
- static member empty =
- { churchId = Guid.Empty
- name = ""
- city = ""
- st = ""
- hasInterface = false
- interfaceAddress = None
- smallGroups = List ()
+ let empty =
+ { Id = ChurchId Guid.Empty
+ Name = ""
+ City = ""
+ State = ""
+ HasVpsInterface = false
+ InterfaceAddress = None
}
- /// Configure EF for this entity
- static member internal configureEF (mb : ModelBuilder) =
- mb.Entity (
- fun m ->
- m.ToTable "Church" |> ignore
- m.Property(fun e -> e.churchId).HasColumnName "ChurchId" |> ignore
- m.Property(fun e -> e.name).HasColumnName("Name").IsRequired () |> ignore
- m.Property(fun e -> e.city).HasColumnName("City").IsRequired () |> ignore
- m.Property(fun e -> e.st).HasColumnName("ST").IsRequired().HasMaxLength 2 |> ignore
- m.Property(fun e -> e.hasInterface).HasColumnName "HasVirtualPrayerRoomInterface" |> ignore
- m.Property(fun e -> e.interfaceAddress).HasColumnName "InterfaceAddress" |> ignore)
- |> ignore
- mb.Model.FindEntityType(typeof).FindProperty("interfaceAddress")
- .SetValueConverter(OptionConverter ())
-
+
/// Preferences for the form and format of the prayer request list
-and [] ListPreferences =
- { /// The Id of the small group to which these preferences belong
- smallGroupId : SmallGroupId
- /// The days after which regular requests expire
- daysToExpire : int
- /// The number of days a new or updated request is considered new
- daysToKeepNew : int
- /// The number of weeks after which long-term requests are flagged for follow-up
- longTermUpdateWeeks : int
- /// The name from which e-mails are sent
- emailFromName : string
- /// The e-mail address from which e-mails are sent
- emailFromAddress : string
- /// The fonts to use in generating the list of prayer requests
- listFonts : string
- /// The color for the prayer request list headings
- headingColor : string
- /// The color for the lines offsetting the prayer request list headings
- lineColor : string
- /// The font size for the headings on the prayer request list
- headingFontSize : int
- /// The font size for the text on the prayer request list
- textFontSize : int
- /// The order in which the prayer requests are sorted
- requestSort : RequestSort
- /// The password used for "small group login" (view-only request list)
- groupPassword : string
- /// The default e-mail type for this class
- defaultEmailType : EmailFormat
- /// Whether this class makes its request list public
- isPublic : bool
- /// The time zone which this class uses (use tzdata names)
- timeZoneId : TimeZoneId
- /// The time zone information
- timeZone : TimeZone
- /// The number of requests displayed per page
- pageSize : int
- /// How the as-of date should be automatically displayed
- asOfDateDisplay : AsOfDateDisplay
+[]
+type ListPreferences =
+ { /// The Id of the small group to which these preferences belong
+ SmallGroupId : SmallGroupId
+
+ /// The days after which regular requests expire
+ DaysToExpire : int
+
+ /// The number of days a new or updated request is considered new
+ DaysToKeepNew : int
+
+ /// The number of weeks after which long-term requests are flagged for follow-up
+ LongTermUpdateWeeks : int
+
+ /// The name from which e-mails are sent
+ EmailFromName : string
+
+ /// The e-mail address from which e-mails are sent
+ EmailFromAddress : string
+
+ /// The fonts to use in generating the list of prayer requests
+ Fonts : string
+
+ /// The color for the prayer request list headings
+ HeadingColor : string
+
+ /// The color for the lines offsetting the prayer request list headings
+ LineColor : string
+
+ /// The font size for the headings on the prayer request list
+ HeadingFontSize : int
+
+ /// The font size for the text on the prayer request list
+ TextFontSize : int
+
+ /// The order in which the prayer requests are sorted
+ RequestSort : RequestSort
+
+ /// The password used for "small group login" (view-only request list)
+ GroupPassword : string
+
+ /// The default e-mail type for this class
+ DefaultEmailType : EmailFormat
+
+ /// Whether this class makes its request list public
+ IsPublic : bool
+
+ /// The time zone which this class uses (use tzdata names)
+ TimeZoneId : TimeZoneId
+
+ /// The number of requests displayed per page
+ PageSize : int
+
+ /// How the as-of date should be automatically displayed
+ AsOfDateDisplay : AsOfDateDisplay
}
- with
+with
+
+ /// The list of fonts to use when displaying request lists (converts "native" to native font stack)
+ member this.FontStack =
+ if this.Fonts = "native" then
+ """system-ui,-apple-system,"Segoe UI",Roboto,Ubuntu,"Liberation Sans",Cantarell,"Helvetica Neue",sans-serif"""
+ else this.Fonts
+
+/// Functions to support list preferences
+module ListPreferences =
+
/// A set of preferences with their default values
- static member empty =
- { smallGroupId = Guid.Empty
- daysToExpire = 14
- daysToKeepNew = 7
- longTermUpdateWeeks = 4
- emailFromName = "PrayerTracker"
- emailFromAddress = "prayer@djs-consulting.com"
- listFonts = "Century Gothic,Tahoma,Luxi Sans,sans-serif"
- headingColor = "maroon"
- lineColor = "navy"
- headingFontSize = 16
- textFontSize = 12
- requestSort = SortByDate
- groupPassword = ""
- defaultEmailType = HtmlFormat
- isPublic = false
- timeZoneId = "America/Denver"
- timeZone = TimeZone.empty
- pageSize = 100
- asOfDateDisplay = NoDisplay
- }
- /// Configure EF for this entity
- static member internal configureEF (mb : ModelBuilder) =
- mb.Entity (
- fun m ->
- m.ToTable "ListPreference" |> ignore
- m.HasKey (fun e -> e.smallGroupId :> obj) |> ignore
- m.Property(fun e -> e.smallGroupId).HasColumnName "SmallGroupId" |> ignore
- m.Property(fun e -> e.daysToKeepNew)
- .HasColumnName("DaysToKeepNew")
- .IsRequired()
- .HasDefaultValue 7
- |> ignore
- m.Property(fun e -> e.daysToExpire)
- .HasColumnName("DaysToExpire")
- .IsRequired()
- .HasDefaultValue 14
- |> ignore
- m.Property(fun e -> e.longTermUpdateWeeks)
- .HasColumnName("LongTermUpdateWeeks")
- .IsRequired()
- .HasDefaultValue 4
- |> ignore
- m.Property(fun e -> e.emailFromName)
- .HasColumnName("EmailFromName")
- .IsRequired()
- .HasDefaultValue "PrayerTracker"
- |> ignore
- m.Property(fun e -> e.emailFromAddress)
- .HasColumnName("EmailFromAddress")
- .IsRequired()
- .HasDefaultValue "prayer@djs-consulting.com"
- |> ignore
- m.Property(fun e -> e.listFonts)
- .HasColumnName("ListFonts")
- .IsRequired()
- .HasDefaultValue "Century Gothic,Tahoma,Luxi Sans,sans-serif"
- |> ignore
- m.Property(fun e -> e.headingColor)
- .HasColumnName("HeadingColor")
- .IsRequired()
- .HasDefaultValue "maroon"
- |> ignore
- m.Property(fun e -> e.lineColor)
- .HasColumnName("LineColor")
- .IsRequired()
- .HasDefaultValue "navy"
- |> ignore
- m.Property(fun e -> e.headingFontSize)
- .HasColumnName("HeadingFontSize")
- .IsRequired()
- .HasDefaultValue 16
- |> ignore
- m.Property(fun e -> e.textFontSize)
- .HasColumnName("TextFontSize")
- .IsRequired()
- .HasDefaultValue 12
- |> ignore
- m.Property(fun e -> e.requestSort)
- .HasColumnName("RequestSort")
- .IsRequired()
- .HasMaxLength(1)
- .HasDefaultValue SortByDate
- |> ignore
- m.Property(fun e -> e.groupPassword)
- .HasColumnName("GroupPassword")
- .IsRequired()
- .HasDefaultValue ""
- |> ignore
- m.Property(fun e -> e.defaultEmailType)
- .HasColumnName("DefaultEmailType")
- .IsRequired()
- .HasDefaultValue HtmlFormat
- |> ignore
- m.Property(fun e -> e.isPublic)
- .HasColumnName("IsPublic")
- .IsRequired()
- .HasDefaultValue false
- |> ignore
- m.Property(fun e -> e.timeZoneId)
- .HasColumnName("TimeZoneId")
- .IsRequired()
- .HasDefaultValue "America/Denver"
- |> ignore
- m.Property(fun e -> e.pageSize)
- .HasColumnName("PageSize")
- .IsRequired()
- .HasDefaultValue 100
- |> ignore
- m.Property(fun e -> e.asOfDateDisplay)
- .HasColumnName("AsOfDateDisplay")
- .IsRequired()
- .HasMaxLength(1)
- .HasDefaultValue NoDisplay
- |> ignore)
- |> ignore
- mb.Model.FindEntityType(typeof).FindProperty("requestSort")
- .SetValueConverter(Converters.RequestSortConverter ())
- mb.Model.FindEntityType(typeof).FindProperty("defaultEmailType")
- .SetValueConverter(Converters.EmailFormatConverter ())
- mb.Model.FindEntityType(typeof).FindProperty("asOfDateDisplay")
- .SetValueConverter(Converters.AsOfDateDisplayConverter ())
+ let empty =
+ { SmallGroupId = SmallGroupId Guid.Empty
+ DaysToExpire = 14
+ DaysToKeepNew = 7
+ LongTermUpdateWeeks = 4
+ EmailFromName = "PrayerTracker"
+ EmailFromAddress = "prayer@bitbadger.solutions"
+ Fonts = "native"
+ HeadingColor = "maroon"
+ LineColor = "navy"
+ HeadingFontSize = 16
+ TextFontSize = 12
+ RequestSort = SortByDate
+ GroupPassword = ""
+ DefaultEmailType = HtmlFormat
+ IsPublic = false
+ TimeZoneId = TimeZoneId "America/Denver"
+ PageSize = 100
+ AsOfDateDisplay = NoDisplay
+ }
/// A member of a small group
-and [] Member =
- { /// The Id of the member
- memberId : MemberId
- /// The Id of the small group to which this member belongs
- smallGroupId : SmallGroupId
- /// The name of the member
- memberName : string
- /// The e-mail address for the member
- email : string
- /// The type of e-mail preferred by this member (see constants)
- format : string option // TODO - do I need a custom formatter for this?
- /// The small group to which this member belongs
- smallGroup : SmallGroup
+[]
+type Member =
+ { /// The ID of the small group member
+ Id : MemberId
+
+ /// The Id of the small group to which this member belongs
+ SmallGroupId : SmallGroupId
+
+ /// The name of the member
+ Name : string
+
+ /// The e-mail address for the member
+ Email : string
+
+ /// The type of e-mail preferred by this member
+ Format : EmailFormat option
}
- with
+
+/// Functions to support small group members
+module Member =
+
/// An empty member
- static member empty =
- { memberId = Guid.Empty
- smallGroupId = Guid.Empty
- memberName = ""
- email = ""
- format = None
- smallGroup = SmallGroup.empty
+ let empty =
+ { Id = MemberId Guid.Empty
+ SmallGroupId = SmallGroupId Guid.Empty
+ Name = ""
+ Email = ""
+ Format = None
}
- /// Configure EF for this entity
- static member internal configureEF (mb : ModelBuilder) =
- mb.Entity (
- fun m ->
- m.ToTable "Member" |> ignore
- m.Property(fun e -> e.memberId).HasColumnName "MemberId" |> ignore
- m.Property(fun e -> e.smallGroupId).HasColumnName "SmallGroupId" |> ignore
- m.Property(fun e -> e.memberName).HasColumnName("MemberName").IsRequired() |> ignore
- m.Property(fun e -> e.email).HasColumnName("Email").IsRequired() |> ignore
- m.Property(fun e -> e.format).HasColumnName "Format" |> ignore)
- |> ignore
- mb.Model.FindEntityType(typeof).FindProperty("format").SetValueConverter(OptionConverter ())
/// This represents a single prayer request
-and [] PrayerRequest =
- { /// The Id of this request
- prayerRequestId : PrayerRequestId
- /// The type of the request
- requestType : PrayerRequestType
- /// The user who entered the request
- userId : UserId
- /// The small group to which this request belongs
- smallGroupId : SmallGroupId
- /// The date/time on which this request was entered
- enteredDate : DateTime
- /// The date/time this request was last updated
- updatedDate : DateTime
- /// The name of the requestor or subject, or title of announcement
- requestor : string option
- /// The text of the request
- text : string
- /// Whether the chaplain should be notified for this request
- notifyChaplain : bool
- /// The user who entered this request
- user : User
- /// The small group to which this request belongs
- smallGroup : SmallGroup
- /// Is this request expired?
- expiration : Expiration
+[]
+type PrayerRequest =
+ { /// The ID of this request
+ Id : PrayerRequestId
+
+ /// The type of the request
+ RequestType : PrayerRequestType
+
+ /// The ID of the user who entered the request
+ UserId : UserId
+
+ /// The small group to which this request belongs
+ SmallGroupId : SmallGroupId
+
+ /// The date/time on which this request was entered
+ EnteredDate : Instant
+
+ /// The date/time this request was last updated
+ UpdatedDate : Instant
+
+ /// The name of the requestor or subject, or title of announcement
+ Requestor : string option
+
+ /// The text of the request
+ Text : string
+
+ /// Whether the chaplain should be notified for this request
+ NotifyChaplain : bool
+
+ /// Is this request expired?
+ Expiration : Expiration
}
- with
- /// An empty request
- static member empty =
- { prayerRequestId = Guid.Empty
- requestType = CurrentRequest
- userId = Guid.Empty
- smallGroupId = Guid.Empty
- enteredDate = DateTime.MinValue
- updatedDate = DateTime.MinValue
- requestor = None
- text = ""
- notifyChaplain = false
- user = User.empty
- smallGroup = SmallGroup.empty
- expiration = Automatic
- }
- /// Is this request expired?
- member this.isExpired (curr : DateTime) expDays =
- match this.expiration with
- | Forced -> true
- | Manual -> false
- | Automatic ->
- match this.requestType with
- | LongTermRequest
- | Expecting -> false
- | _ -> curr.AddDays(-(float expDays)).Date > this.updatedDate.Date // Automatic expiration
-
- /// Is an update required for this long-term request?
- member this.updateRequired curr expDays updWeeks =
- match this.isExpired curr expDays with
- | true -> false
- | false -> curr.AddDays(-(float (updWeeks * 7))).Date > this.updatedDate.Date
-
- /// Configure EF for this entity
- static member internal configureEF (mb : ModelBuilder) =
- mb.Entity (
- fun m ->
- m.ToTable "PrayerRequest" |> ignore
- m.Property(fun e -> e.prayerRequestId).HasColumnName "PrayerRequestId" |> ignore
- m.Property(fun e -> e.requestType).HasColumnName("RequestType").IsRequired() |> ignore
- m.Property(fun e -> e.userId).HasColumnName "UserId" |> ignore
- m.Property(fun e -> e.smallGroupId).HasColumnName "SmallGroupId" |> ignore
- m.Property(fun e -> e.enteredDate).HasColumnName "EnteredDate" |> ignore
- m.Property(fun e -> e.updatedDate).HasColumnName "UpdatedDate" |> ignore
- m.Property(fun e -> e.requestor).HasColumnName "Requestor" |> ignore
- m.Property(fun e -> e.text).HasColumnName("Text").IsRequired() |> ignore
- m.Property(fun e -> e.notifyChaplain).HasColumnName "NotifyChaplain" |> ignore
- m.Property(fun e -> e.expiration).HasColumnName "Expiration" |> ignore)
- |> ignore
- mb.Model.FindEntityType(typeof).FindProperty("requestType")
- .SetValueConverter(Converters.PrayerRequestTypeConverter ())
- mb.Model.FindEntityType(typeof).FindProperty("requestor")
- .SetValueConverter(OptionConverter ())
- mb.Model.FindEntityType(typeof).FindProperty("expiration")
- .SetValueConverter(Converters.ExpirationConverter ())
+// functions are below small group functions
/// This represents a small group (Sunday School class, Bible study group, etc.)
-and [] SmallGroup =
- { /// The Id of this small group
- smallGroupId : SmallGroupId
- /// The church to which this group belongs
- churchId : ChurchId
- /// The name of the group
- name : string
- /// The church to which this small group belongs
- church : Church
- /// The preferences for the request list
- preferences : ListPreferences
- /// The members of the group
- members : ICollection
- /// Prayer requests for this small group
- prayerRequests : ICollection
- /// The users authorized to manage this group
- users : ICollection
+[]
+type SmallGroup =
+ { /// The ID of this small group
+ Id : SmallGroupId
+
+ /// The church to which this group belongs
+ ChurchId : ChurchId
+
+ /// The name of the group
+ Name : string
+
+ /// The preferences for the request list
+ Preferences : ListPreferences
}
- with
- /// An empty small group
- static member empty =
- { smallGroupId = Guid.Empty
- churchId = Guid.Empty
- name = ""
- church = Church.empty
- preferences = ListPreferences.empty
- members = List ()
- prayerRequests = List ()
- users = List ()
- }
- /// Get the local date for this group
- member this.localTimeNow (clock : IClock) =
- match clock with null -> nullArg "clock" | _ -> ()
- let tz =
- match DateTimeZoneProviders.Tzdb.Ids.Contains this.preferences.timeZoneId with
- | true -> DateTimeZoneProviders.Tzdb.[this.preferences.timeZoneId]
- | false -> DateTimeZone.Utc
- clock.GetCurrentInstant().InZone(tz).ToDateTimeUnspecified()
-
- /// Get the local date for this group
- member this.localDateNow clock =
- (this.localTimeNow clock).Date
+/// Functions to support small groups
+module SmallGroup =
- /// Configure EF for this entity
- static member internal configureEF (mb : ModelBuilder) =
- mb.Entity (
- fun m ->
- m.ToTable "SmallGroup" |> ignore
- m.Property(fun e -> e.smallGroupId).HasColumnName "SmallGroupId" |> ignore
- m.Property(fun e -> e.churchId).HasColumnName "ChurchId" |> ignore
- m.Property(fun e -> e.name).HasColumnName("Name").IsRequired() |> ignore
- m.HasOne(fun e -> e.preferences) |> ignore)
- |> ignore
-
-
-/// This represents a time zone in which a class may reside
-and [] TimeZone =
- { /// The Id for this time zone (uses tzdata names)
- timeZoneId : TimeZoneId
- /// The description of this time zone
- description : string
- /// The order in which this timezone should be displayed
- sortOrder : int
- /// Whether this timezone is active
- isActive : bool
- }
- with
- /// An empty time zone
- static member empty =
- { timeZoneId = ""
- description = ""
- sortOrder = 0
- isActive = false
+ /// An empty small group
+ let empty =
+ { Id = SmallGroupId Guid.Empty
+ ChurchId = ChurchId Guid.Empty
+ Name = ""
+ Preferences = ListPreferences.empty
}
- /// Configure EF for this entity
- static member internal configureEF (mb : ModelBuilder) =
- mb.Entity (
- fun m ->
- m.ToTable "TimeZone" |> ignore
- m.Property(fun e -> e.timeZoneId).HasColumnName "TimeZoneId" |> ignore
- m.Property(fun e -> e.description).HasColumnName("Description").IsRequired() |> ignore
- m.Property(fun e -> e.sortOrder).HasColumnName "SortOrder" |> ignore
- m.Property(fun e -> e.isActive).HasColumnName "IsActive" |> ignore)
- |> ignore
+
+ /// The DateTimeZone for the time zone ID for this small group
+ let timeZone group =
+ let tzId = TimeZoneId.toString group.Preferences.TimeZoneId
+ if DateTimeZoneProviders.Tzdb.Ids.Contains tzId then DateTimeZoneProviders.Tzdb[tzId]
+ else DateTimeZone.Utc
+
+ /// Get the local date/time for this group
+ let localTimeNow (clock : IClock) group =
+ if isNull clock then nullArg (nameof clock)
+ clock.GetCurrentInstant().InZone(timeZone group).LocalDateTime
+
+ /// Get the local date for this group
+ let localDateNow clock group =
+ (localTimeNow clock group).Date
+
+
+/// Functions to support prayer requests
+module PrayerRequest =
+
+ /// An empty request
+ let empty =
+ { Id = PrayerRequestId Guid.Empty
+ RequestType = CurrentRequest
+ UserId = UserId Guid.Empty
+ SmallGroupId = SmallGroupId Guid.Empty
+ EnteredDate = Instant.MinValue
+ UpdatedDate = Instant.MinValue
+ Requestor = None
+ Text = ""
+ NotifyChaplain = false
+ Expiration = Automatic
+ }
+
+ /// Is this request expired?
+ let isExpired (asOf : LocalDate) group req =
+ match req.Expiration, req.RequestType with
+ | Forced, _ -> true
+ | Manual, _
+ | Automatic, LongTermRequest
+ | Automatic, Expecting -> false
+ | Automatic, _ ->
+ // Automatic expiration
+ Period.Between(req.UpdatedDate.InZone(SmallGroup.timeZone group).Date, asOf, PeriodUnits.Days).Days
+ >= group.Preferences.DaysToExpire
+
+ /// Is an update required for this long-term request?
+ let updateRequired asOf group req =
+ if isExpired asOf group req then false
+ else asOf.PlusWeeks -group.Preferences.LongTermUpdateWeeks
+ >= req.UpdatedDate.InZone(SmallGroup.timeZone group).Date
/// This represents a user of PrayerTracker
-and [] User =
- { /// The Id of this user
- userId : UserId
- /// The first name of this user
- firstName : string
- /// The last name of this user
- lastName : string
- /// The e-mail address of the user
- emailAddress : string
- /// Whether this user is a PrayerTracker system administrator
- isAdmin : bool
- /// The user's hashed password
- passwordHash : string
- /// The salt for the user's hashed password
- salt : Guid option
- /// The small groups which this user is authorized
- smallGroups : ICollection
+[]
+type User =
+ { /// The ID of this user
+ Id : UserId
+
+ /// The first name of this user
+ FirstName : string
+
+ /// The last name of this user
+ LastName : string
+
+ /// The e-mail address of the user
+ Email : string
+
+ /// Whether this user is a PrayerTracker system administrator
+ IsAdmin : bool
+
+ /// The user's hashed password
+ PasswordHash : string
+
+ /// The last time the user was seen (set whenever the user is loaded into a session)
+ LastSeen : Instant option
}
- with
- /// An empty user
- static member empty =
- { userId = Guid.Empty
- firstName = ""
- lastName = ""
- emailAddress = ""
- isAdmin = false
- passwordHash = ""
- salt = None
- smallGroups = List ()
- }
+with
/// The full name of the user
- member this.fullName =
- sprintf "%s %s" this.firstName this.lastName
+ member this.Name =
+ $"{this.FirstName} {this.LastName}"
- /// Configure EF for this entity
- static member internal configureEF (mb : ModelBuilder) =
- mb.Entity (
- fun m ->
- m.ToTable "User" |> ignore
- m.Ignore(fun e -> e.fullName :> obj) |> ignore
- m.Property(fun e -> e.userId).HasColumnName "UserId" |> ignore
- m.Property(fun e -> e.firstName).HasColumnName("FirstName").IsRequired() |> ignore
- m.Property(fun e -> e.lastName).HasColumnName("LastName").IsRequired() |> ignore
- m.Property(fun e -> e.emailAddress).HasColumnName("EmailAddress").IsRequired() |> ignore
- m.Property(fun e -> e.isAdmin).HasColumnName "IsSystemAdmin" |> ignore
- m.Property(fun e -> e.passwordHash).HasColumnName("PasswordHash").IsRequired() |> ignore
- m.Property(fun e -> e.salt).HasColumnName "Salt" |> ignore)
- |> ignore
- mb.Model.FindEntityType(typeof).FindProperty("salt")
- .SetValueConverter(OptionConverter ())
+/// Functions to support users
+module User =
+
+ /// An empty user
+ let empty =
+ { Id = UserId Guid.Empty
+ FirstName = ""
+ LastName = ""
+ Email = ""
+ IsAdmin = false
+ PasswordHash = ""
+ LastSeen = None
+ }
/// Cross-reference between user and small group
-and [] UserSmallGroup =
- { /// The Id of the user who has access to the small group
- userId : UserId
- /// The Id of the small group to which the user has access
- smallGroupId : SmallGroupId
- /// The user who has access to the small group
- user : User
- /// The small group to which the user has access
- smallGroup : SmallGroup
+[]
+type UserSmallGroup =
+ { /// The Id of the user who has access to the small group
+ UserId : UserId
+
+ /// The Id of the small group to which the user has access
+ SmallGroupId : SmallGroupId
}
- with
+
+/// Functions to support user/small group cross-reference
+module UserSmallGroup =
+
/// An empty user/small group xref
- static member empty =
- { userId = Guid.Empty
- smallGroupId = Guid.Empty
- user = User.empty
- smallGroup = SmallGroup.empty
+ let empty =
+ { UserId = UserId Guid.Empty
+ SmallGroupId = SmallGroupId Guid.Empty
}
- /// Configure EF for this entity
- static member internal configureEF (mb : ModelBuilder) =
- mb.Entity (
- fun m ->
- m.ToTable "User_SmallGroup" |> ignore
- m.HasKey(fun e -> { userId = e.userId; smallGroupId = e.smallGroupId } :> obj) |> ignore
- m.Property(fun e -> e.userId).HasColumnName "UserId" |> ignore
- m.Property(fun e -> e.smallGroupId).HasColumnName "SmallGroupId" |> ignore
- m.HasOne(fun e -> e.user)
- .WithMany(fun e -> e.smallGroups :> IEnumerable)
- .HasForeignKey(fun e -> e.userId :> obj)
- |> ignore
- m.HasOne(fun e -> e.smallGroup)
- .WithMany(fun e -> e.users :> IEnumerable)
- .HasForeignKey(fun e -> e.smallGroupId :> obj)
- |> ignore)
- |> ignore
diff --git a/src/PrayerTracker.Data/Migrations/20161217153124_InitialDatabase.fs b/src/PrayerTracker.Data/Migrations/20161217153124_InitialDatabase.fs
deleted file mode 100644
index c228771..0000000
--- a/src/PrayerTracker.Data/Migrations/20161217153124_InitialDatabase.fs
+++ /dev/null
@@ -1,514 +0,0 @@
-namespace PrayerTracker.Migrations
-
-open Microsoft.EntityFrameworkCore
-open Microsoft.EntityFrameworkCore.Infrastructure
-open Microsoft.EntityFrameworkCore.Migrations
-open Microsoft.EntityFrameworkCore.Migrations.Operations
-open Microsoft.EntityFrameworkCore.Migrations.Operations.Builders
-open Npgsql.EntityFrameworkCore.PostgreSQL.Metadata
-open PrayerTracker
-open PrayerTracker.Entities
-open System
-
-// fsharplint:disable RecordFieldNames
-
-type ChurchTable =
- { churchId : OperationBuilder
- city : OperationBuilder
- hasInterface : OperationBuilder
- interfaceAddress : OperationBuilder
- name : OperationBuilder
- st : OperationBuilder
- }
-
-type ListPreferencesTable =
- { smallGroupId : OperationBuilder
- daysToExpire : OperationBuilder
- daysToKeepNew : OperationBuilder
- defaultEmailType : OperationBuilder
- emailFromAddress : OperationBuilder
- emailFromName : OperationBuilder
- groupPassword : OperationBuilder
- headingColor : OperationBuilder
- headingFontSize : OperationBuilder
- isPublic : OperationBuilder
- lineColor : OperationBuilder
- listFonts : OperationBuilder
- longTermUpdateWeeks : OperationBuilder
- requestSort : OperationBuilder
- textFontSize : OperationBuilder
- timeZoneId : OperationBuilder
- pageSize : OperationBuilder
- asOfDateDisplay : OperationBuilder
- }
-
-type MemberTable =
- { memberId : OperationBuilder
- email : OperationBuilder
- format : OperationBuilder
- memberName : OperationBuilder
- smallGroupId : OperationBuilder
- }
-
-type PrayerRequestTable =
- { prayerRequestId : OperationBuilder
- enteredDate : OperationBuilder
- expiration : OperationBuilder
- notifyChaplain : OperationBuilder
- requestType : OperationBuilder
- requestor : OperationBuilder
- smallGroupId : OperationBuilder
- text : OperationBuilder
- updatedDate : OperationBuilder
- userId : OperationBuilder
- }
-
-type SmallGroupTable =
- { smallGroupId : OperationBuilder
- churchId : OperationBuilder
- name : OperationBuilder
- }
-
-type TimeZoneTable =
- { timeZoneId : OperationBuilder
- description : OperationBuilder
- isActive : OperationBuilder
- sortOrder : OperationBuilder
- }
-
-type UserSmallGroupTable =
- { userId : OperationBuilder
- smallGroupId : OperationBuilder
- }
-
-type UserTable =
- { userId : OperationBuilder
- emailAddress : OperationBuilder
- firstName : OperationBuilder
- isAdmin : OperationBuilder
- lastName : OperationBuilder
- passwordHash : OperationBuilder
- salt : OperationBuilder
- }
-
-[)>]
-[]
-type InitialDatabase () =
- inherit Migration ()
- override __.Up (migrationBuilder : MigrationBuilder) =
- migrationBuilder.EnsureSchema (name = "pt")
- |> ignore
-
- migrationBuilder.CreateTable (
- name = "Church",
- schema = "pt",
- columns =
- (fun table ->
- { churchId = table.Column (name = "ChurchId", nullable = false)
- city = table.Column (name = "City", nullable = false)
- hasInterface = table.Column (name = "HasVirtualPrayerRoomInterface", nullable = false)
- interfaceAddress = table.Column (name = "InterfaceAddress", nullable = true)
- name = table.Column (name = "Name", nullable = false)
- st = table.Column (name = "ST", nullable = false, maxLength = Nullable 2)
- }),
- constraints =
- fun table ->
- table.PrimaryKey ("PK_Church", fun x -> upcast x.churchId) |> ignore)
- |> ignore
-
- migrationBuilder.CreateTable (
- name = "TimeZone",
- schema = "pt",
- columns =
- (fun table ->
- { timeZoneId = table.Column (name = "TimeZoneId", nullable = false)
- description = table.Column (name = "Description", nullable = false)
- isActive = table.Column (name = "IsActive", nullable = false)
- sortOrder = table.Column (name = "SortOrder", nullable = false)
- }),
- constraints =
- fun table ->
- table.PrimaryKey ("PK_TimeZone", fun x -> upcast x.timeZoneId) |> ignore)
- |> ignore
-
- migrationBuilder.CreateTable (
- name = "User",
- schema = "pt",
- columns =
- (fun table ->
- { userId = table.Column (name = "UserId", nullable = false)
- emailAddress = table.Column (name = "EmailAddress", nullable = false)
- firstName = table.Column (name = "FirstName", nullable = false)
- isAdmin = table.Column (name = "IsSystemAdmin", nullable = false)
- lastName = table.Column (name = "LastName", nullable = false)
- passwordHash = table.Column (name = "PasswordHash", nullable = false)
- salt = table.Column (name = "Salt", nullable = true)
- }),
- constraints =
- fun table ->
- table.PrimaryKey("PK_User", fun x -> upcast x.userId) |> ignore)
- |> ignore
-
- migrationBuilder.CreateTable (
- name = "SmallGroup",
- schema = "pt",
- columns =
- (fun table ->
- { smallGroupId = table.Column (name = "SmallGroupId", nullable = false)
- churchId = table.Column (name = "ChurchId", nullable = false)
- name = table.Column (name = "Name", nullable = false)
- }),
- constraints =
- fun table ->
- table.PrimaryKey ("PK_SmallGroup", fun x -> upcast x.smallGroupId) |> ignore
- table.ForeignKey (
- name = "FK_SmallGroup_Church_ChurchId",
- column = (fun x -> upcast x.churchId),
- principalSchema = "pt",
- principalTable = "Church",
- principalColumn = "ChurchId",
- onDelete = ReferentialAction.Cascade)
- |> ignore)
- |> ignore
-
- migrationBuilder.CreateTable (
- name = "ListPreference",
- schema = "pt",
- columns =
- (fun table ->
- { smallGroupId = table.Column (name = "SmallGroupId", nullable = false)
- daysToExpire = table.Column (name = "DaysToExpire", nullable = false, defaultValue = 14)
- daysToKeepNew = table.Column (name = "DaysToKeepNew", nullable = false, defaultValue = 7)
- defaultEmailType = table.Column (name = "DefaultEmailType", nullable = false, defaultValue = "Html")
- emailFromAddress = table.Column (name = "EmailFromAddress", nullable = false, defaultValue = "prayer@djs-consulting.com")
- emailFromName = table.Column (name = "EmailFromName", nullable = false, defaultValue = "PrayerTracker")
- groupPassword = table.Column (name = "GroupPassword", nullable = false, defaultValue = "")
- headingColor = table.Column (name = "HeadingColor", nullable = false, defaultValue = "maroon")
- headingFontSize = table.Column (name = "HeadingFontSize", nullable = false, defaultValue = 16)
- isPublic = table.Column (name = "IsPublic", nullable = false, defaultValue = false)
- lineColor = table.Column (name = "LineColor", nullable = false, defaultValue = "navy")
- listFonts = table.Column (name = "ListFonts", nullable = false, defaultValue = "Century Gothic,Tahoma,Luxi Sans,sans-serif")
- longTermUpdateWeeks = table.Column (name = "LongTermUpdateWeeks", nullable = false, defaultValue = 4)
- requestSort = table.Column (name = "RequestSort", nullable = false, defaultValue = "D", maxLength = Nullable 1)
- textFontSize = table.Column (name = "TextFontSize", nullable = false, defaultValue = 12)
- timeZoneId = table.Column (name = "TimeZoneId", nullable = false, defaultValue = "America/Denver")
- pageSize = table.Column (name = "PageSize", nullable = false, defaultValue = 100)
- asOfDateDisplay = table.Column (name = "AsOfDateDisplay", nullable = false, defaultValue = "N", maxLength = Nullable 1)
- }),
- constraints =
- fun table ->
- table.PrimaryKey ("PK_ListPreference", fun x -> upcast x.smallGroupId) |> ignore
- table.ForeignKey (
- name = "FK_ListPreference_SmallGroup_SmallGroupId",
- column = (fun x -> upcast x.smallGroupId),
- principalSchema = "pt",
- principalTable = "SmallGroup",
- principalColumn = "SmallGroupId",
- onDelete = ReferentialAction.Cascade)
- |> ignore
- table.ForeignKey (
- name = "FK_ListPreference_TimeZone_TimeZoneId",
- column = (fun x -> upcast x.timeZoneId),
- principalSchema = "pt",
- principalTable = "TimeZone",
- principalColumn = "TimeZoneId",
- onDelete = ReferentialAction.Cascade)
- |> ignore)
- |> ignore
-
- migrationBuilder.CreateTable (
- name = "Member",
- schema = "pt",
- columns =
- (fun table ->
- { memberId = table.Column (name = "MemberId", nullable = false)
- email = table.Column (name = "Email", nullable = false)
- format = table.Column (name = "Format", nullable = true)
- memberName = table.Column (name = "MemberName", nullable = false)
- smallGroupId = table.Column (name = "SmallGroupId", nullable = false)
- }),
- constraints =
- fun table ->
- table.PrimaryKey ("PK_Member", fun x -> upcast x.memberId) |> ignore
- table.ForeignKey (
- name = "FK_Member_SmallGroup_SmallGroupId",
- column = (fun x -> upcast x.smallGroupId),
- principalSchema = "pt",
- principalTable = "SmallGroup",
- principalColumn = "SmallGroupId",
- onDelete = ReferentialAction.Cascade)
- |> ignore)
- |> ignore
-
- migrationBuilder.CreateTable (
- name = "PrayerRequest",
- schema = "pt",
- columns =
- (fun table ->
- { prayerRequestId = table.Column (name = "PrayerRequestId", nullable = false)
- expiration = table.Column (name = "Expiration", nullable = false)
- enteredDate = table.Column (name = "EnteredDate", nullable = false)
- notifyChaplain = table.Column (name = "NotifyChaplain", nullable = false)
- requestType = table.Column (name = "RequestType", nullable = false)
- requestor = table.Column (name = "Requestor", nullable = true)
- smallGroupId = table.Column (name = "SmallGroupId", nullable = false)
- text = table.Column (name = "Text", nullable = false)
- updatedDate = table.Column (name = "UpdatedDate", nullable = false)
- userId = table.Column (name = "UserId", nullable = false)
- }),
- constraints =
- fun table ->
- table.PrimaryKey ("PK_PrayerRequest", fun x -> upcast x.prayerRequestId) |> ignore
- table.ForeignKey (
- name = "FK_PrayerRequest_SmallGroup_SmallGroupId",
- column = (fun x -> upcast x.smallGroupId),
- principalSchema = "pt",
- principalTable = "SmallGroup",
- principalColumn = "SmallGroupId",
- onDelete = ReferentialAction.Cascade)
- |> ignore
- table.ForeignKey (
- name = "FK_PrayerRequest_User_UserId",
- column = (fun x -> upcast x.userId),
- principalSchema = "pt",
- principalTable = "User",
- principalColumn = "UserId",
- onDelete = ReferentialAction.Cascade)
- |> ignore)
- |> ignore
-
- migrationBuilder.CreateTable(
- name = "User_SmallGroup",
- schema = "pt",
- columns =
- (fun table ->
- { userId = table.Column (name = "UserId", nullable = false)
- smallGroupId = table.Column (name = "SmallGroupId", nullable = false)
- }),
- constraints =
- fun table ->
- table.PrimaryKey ("PK_User_SmallGroup", fun x -> upcast x) |> ignore
- table.ForeignKey (
- name = "FK_User_SmallGroup_SmallGroup_SmallGroupId",
- column = (fun x -> upcast x.smallGroupId),
- principalSchema = "pt",
- principalTable = "SmallGroup",
- principalColumn = "SmallGroupId",
- onDelete = ReferentialAction.Cascade)
- |> ignore
- table.ForeignKey (
- name = "FK_User_SmallGroup_User_UserId",
- column = (fun x -> upcast x.userId),
- principalSchema = "pt",
- principalTable = "User",
- principalColumn = "UserId",
- onDelete = ReferentialAction.Cascade)
- |> ignore)
- |> ignore
-
- migrationBuilder.CreateIndex (name = "IX_ListPreference_TimeZoneId", schema = "pt", table = "ListPreference", column = "TimeZoneId") |> ignore
- migrationBuilder.CreateIndex (name = "IX_Member_SmallGroupId", schema = "pt", table = "Member", column = "SmallGroupId") |> ignore
- migrationBuilder.CreateIndex (name = "IX_PrayerRequest_SmallGroupId", schema = "pt", table = "PrayerRequest", column = "SmallGroupId") |> ignore
- migrationBuilder.CreateIndex (name = "IX_PrayerRequest_UserId", schema = "pt", table = "PrayerRequest", column = "UserId") |> ignore
- migrationBuilder.CreateIndex (name = "IX_SmallGroup_ChurchId", schema = "pt", table = "SmallGroup", column = "ChurchId") |> ignore
- migrationBuilder.CreateIndex (name = "IX_User_SmallGroup_SmallGroupId", schema = "pt", table = "User_SmallGroup", column = "SmallGroupId") |> ignore
-
- override __.Down (migrationBuilder : MigrationBuilder) =
- migrationBuilder.DropTable (name = "ListPreference", schema = "pt") |> ignore
- migrationBuilder.DropTable (name = "Member", schema = "pt") |> ignore
- migrationBuilder.DropTable (name = "PrayerRequest", schema = "pt") |> ignore
- migrationBuilder.DropTable (name = "User_SmallGroup", schema = "pt") |> ignore
- migrationBuilder.DropTable (name = "TimeZone", schema = "pt") |> ignore
- migrationBuilder.DropTable (name = "SmallGroup", schema = "pt") |> ignore
- migrationBuilder.DropTable (name = "User", schema = "pt") |> ignore
- migrationBuilder.DropTable (name = "Church", schema = "pt") |> ignore
-
-
- override __.BuildTargetModel (modelBuilder : ModelBuilder) =
- modelBuilder
- .HasDefaultSchema("pt")
- .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
- .HasAnnotation("ProductVersion", "1.1.0-rtm-22752")
- |> ignore
-
- modelBuilder.Entity (
- typeof,
- fun b ->
- b.Property("churchId").ValueGeneratedOnAdd() |> ignore
- b.Property("city").IsRequired() |> ignore
- b.Property("hasInterface") |> ignore
- b.Property("interfaceAddress") |> ignore
- b.Property("name").IsRequired() |> ignore
- b.Property("st").IsRequired().HasMaxLength(2) |> ignore
- b.HasKey("churchId") |> ignore
- b.ToTable("Church") |> ignore)
- |> ignore
-
- modelBuilder.Entity (
- typeof,
- fun b ->
- b.Property("smallGroupId") |> ignore
- b.Property("daysToExpire").ValueGeneratedOnAdd().HasDefaultValue(14) |> ignore
- b.Property("daysToKeepNew").ValueGeneratedOnAdd().HasDefaultValue(7) |> ignore
- b.Property("defaultEmailType").IsRequired().ValueGeneratedOnAdd().HasDefaultValue("H") |> ignore
- b.Property("emailFromAddress").IsRequired().ValueGeneratedOnAdd().HasDefaultValue("prayer@djs-consulting.com") |> ignore
- b.Property("emailFromName").IsRequired().ValueGeneratedOnAdd().HasDefaultValue("PrayerTracker") |> ignore
- b.Property("groupPassword").IsRequired().ValueGeneratedOnAdd().HasDefaultValue("") |> ignore
- b.Property("headingColor").IsRequired().ValueGeneratedOnAdd().HasDefaultValue("maroon") |> ignore
- b.Property("headingFontSize").ValueGeneratedOnAdd().HasDefaultValue(16) |> ignore
- b.Property("isPublic").ValueGeneratedOnAdd().HasDefaultValue(false) |> ignore
- b.Property("lineColor").IsRequired().ValueGeneratedOnAdd().HasDefaultValue("navy") |> ignore
- b.Property("listFonts").IsRequired().ValueGeneratedOnAdd().HasDefaultValue("Century Gothic,Tahoma,Luxi Sans,sans-serif") |> ignore
- b.Property("longTermUpdateWeeks").ValueGeneratedOnAdd().HasDefaultValue(4) |> ignore
- b.Property("requestSort").IsRequired().ValueGeneratedOnAdd().HasDefaultValue("D").HasMaxLength(1) |> ignore
- b.Property("textFontSize").ValueGeneratedOnAdd().HasDefaultValue(12) |> ignore
- b.Property("timeZoneId").IsRequired().ValueGeneratedOnAdd().HasDefaultValue("America/Denver") |> ignore
- b.Property("pageSize").IsRequired().ValueGeneratedOnAdd().HasDefaultValue(100) |> ignore
- b.Property("asOfDateDisplay").IsRequired().ValueGeneratedOnAdd().HasDefaultValue("N").HasMaxLength(1) |> ignore
- b.HasKey("smallGroupId") |> ignore
- b.HasIndex("timeZoneId") |> ignore
- b.ToTable("ListPreference") |> ignore)
- |> ignore
-
- modelBuilder.Entity (
- typeof,
- fun b ->
- b.Property("memberId").ValueGeneratedOnAdd() |> ignore
- b.Property("email").IsRequired() |> ignore
- b.Property("format") |> ignore
- b.Property("memberName").IsRequired() |> ignore
- b.Property("smallGroupId") |> ignore
- b.HasKey("memberId") |> ignore
- b.HasIndex("smallGroupId") |> ignore
- b.ToTable("Member") |> ignore)
- |> ignore
-
- modelBuilder.Entity (
- typeof,
- fun b ->
- b.Property