public void CreatePermission(Users User, Props.Permission Permission) { using (var db = new CoreContext()) { Models.UserPermissions permission = new Models.UserPermissions() { PermissionName = Permission.Name(), PermissionValue = Permission.Value(), UserId = User.UserId, Users = User }; db.UserPermissions.Add(permission); db.SaveChanges(); } }
public void UpdatePermission(Users User, Props.Permission Permission) { using (var db = new CoreContext()) { var permSearch = db.UserPermissions.SingleOrDefault(x => x.UserId == User.UserId && x.PermissionName == Permission.Name()); permSearch.PermissionValue = Permission.Value(); db.SaveChanges(); } }
public Props.Permission GetPermission(Users User, Props.Permission Permission, bool includeNativePermissions = false) { using (var db = new CoreContext()) { var permSearch = db.UserPermissions.Single(x => x.UserId == User.UserId && x.PermissionName == Permission.Name()); return(new Props.Permission(permSearch.PermissionName, permSearch.PermissionValue)); } }
public void DeletePermission(Users User, Props.Permission Permission) { using (var db = new CoreContext()) { var permSearch = db.UserPermissions.SingleOrDefault(x => x.UserId == User.UserId && x.PermissionName == Permission.Name()); if (permSearch != null) { db.UserPermissions.Remove(permSearch); db.SaveChanges(); } } }