public async Task CreateSectionAsync(SectionEdit newValues, IUser?currentUser)
        {
            var ds = DataSource(currentUser);

            await CheckPermissionPartAsync(newValues.PartKey, currentUser);

            if (newValues.ParentSectionKey.HasValue)
            {
                var parentPartKey = await ds.From("Sources.Section", new { SectionKey = newValues.ParentSectionKey }).ToInt32("PartKey").ExecuteAsync();

                if (parentPartKey != newValues.PartKey)
                {
                    throw new InvalidOperationException("Parent Section is not in the same book/part as this section.");
                }
            }

            if (string.IsNullOrWhiteSpace(newValues.PageReference))
            {
                newValues.PageReference = null;
            }

            await ds.Insert("Sources.Section", newValues).AsNonQuery().ClearCache().ExecuteAsync();

            return;
        }
        public async Task UpdateSectionEditAsync(SectionEdit newValues, IUser?currentUser)
        {
            var ds = DataSource(currentUser);

            var oldValues = (await ds.From("Sources.Section", new { newValues.SectionKey }).ToObject <SectionEdit>().ExecuteAsync());

            await CheckPermissionSectionAsync(oldValues.SectionKey !.Value, currentUser);

            if (oldValues.PartKey != newValues.PartKey)
            {
                throw new InvalidOperationException("Cannot move section to a different book/part.");
            }

            if (newValues.ParentSectionKey.HasValue)
            {
                var parentPartKey = await ds.From("Sources.Section", new { SectionKey = newValues.ParentSectionKey }).ToInt32("PartKey").ExecuteAsync();

                if (parentPartKey != newValues.PartKey)
                {
                    throw new InvalidOperationException("Parent Section is not in the same book/part as this section.");
                }
            }

            if (string.IsNullOrWhiteSpace(newValues.PageReference))
            {
                newValues.PageReference = null;
            }

            await ds.Update("Sources.Section", newValues).AsNonQuery().ClearCache().ExecuteAsync();

            return;
        }