aboutsummaryrefslogtreecommitdiff
path: root/VNLib.Plugins.Essentials.Accounts.Admin/Model/UserStore.cs
diff options
context:
space:
mode:
authorLibravatar vman <public@vaughnnugent.com>2022-11-18 16:08:51 -0500
committerLibravatar vman <public@vaughnnugent.com>2022-11-18 16:08:51 -0500
commit526c2364b9ad685d1c000fc8a168bf1305aaa8b7 (patch)
treea2bc01607320a6a75e1a869d5bd34e79fd63c595 /VNLib.Plugins.Essentials.Accounts.Admin/Model/UserStore.cs
parent2080400119be00bdc354f3121d84ec2f89606ac7 (diff)
Add project files.
Diffstat (limited to 'VNLib.Plugins.Essentials.Accounts.Admin/Model/UserStore.cs')
-rw-r--r--VNLib.Plugins.Essentials.Accounts.Admin/Model/UserStore.cs48
1 files changed, 48 insertions, 0 deletions
diff --git a/VNLib.Plugins.Essentials.Accounts.Admin/Model/UserStore.cs b/VNLib.Plugins.Essentials.Accounts.Admin/Model/UserStore.cs
new file mode 100644
index 0000000..b3e5c23
--- /dev/null
+++ b/VNLib.Plugins.Essentials.Accounts.Admin/Model/UserStore.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using Microsoft.EntityFrameworkCore;
+
+using VNLib.Plugins.Extensions.Data;
+
+namespace VNLib.Plugins.Essentials.Accounts.Admin.Model
+{
+
+ internal class UserStore : DbStore<User>
+ {
+ private readonly DbContextOptions Options;
+
+ public UserStore(DbContextOptions options)
+ {
+ this.Options = options;
+ }
+
+ //Item id's are not used
+ public override string RecordIdBuilder => "";
+
+ protected override IQueryable<User> GetCollectionQueryBuilder(TransactionalDbContext context, params string[] constraints)
+ {
+ return (from user in context.Set<User>()
+ orderby user.Created descending
+ select user);
+ }
+
+ protected override IQueryable<User> GetSingleQueryBuilder(TransactionalDbContext context, params string[] constraints)
+ {
+ string userId = constraints[0];
+ return (from user in context.Set<User>()
+ where user.UserId == userId
+ select user);
+ }
+
+ public override TransactionalDbContext NewContext() => new UserContext(Options);
+
+ protected override void OnRecordUpdate(User newRecord, User currentRecord)
+ {
+ currentRecord.Privilages = currentRecord.Privilages;
+ }
+ }
+}