Пример #1
0
        private void ThrowIfFound(string contributorId, AppContributorPermission permission, Func <string> message)
        {
            if (contributors.TryGetValue(contributorId, out var currentPermission) && currentPermission == permission)
            {
                var error = new ValidationError("Contributor is already part of the app with same permissions.", "ContributorId");

                throw new ValidationException(message(), error);
            }
        }
Пример #2
0
        public void Assign(string contributorId, AppContributorPermission permission)
        {
            string Message() => "Cannot assign contributor";

            ThrowIfFound(contributorId, permission, Message);
            ThrowIfNoOwner(c => c[contributorId] = permission, Message);

            contributors[contributorId] = permission;
        }
Пример #3
0
        public static AppPermission ToAppPermission(this AppContributorPermission contributorPermission)
        {
            Guard.Enum(contributorPermission, nameof(contributorPermission));

            return((AppPermission)Enum.Parse(typeof(AppPermission), contributorPermission.ToString()));
        }