Example #1
0
        public async Task <DomainResult> UpsertAsync(
            Guid userId,
            SecuritySettingsSection publications,
            SecuritySettingsSection friends)
        {
            var profile = await profileStorage.FindByIdAsync(userId);

            if (profile == null)
            {
                return(DomainResult.Error("User not found"));
            }

            var securitySettings = await securitySettingsStorage.FindByUserIdAsync(userId);

            if (securitySettings == null)
            {
                securitySettings = new SecuritySetting(userId, publications, friends);
            }
            else
            {
                securitySettings.Update(publications, friends);
            }

            await securitySettingsStorage.UpsertAsync(securitySettings);

            return(DomainResult.Success());
        }
Example #2
0
        public async Task <SecuritySetting> GetByUserIdAsync(Guid userId)
        {
            if (await profileStorage.FindByIdAsync(userId) == null)
            {
                return(null);
            }

            var securitySettings = await securitySettingsStorage.FindByUserIdAsync(userId);

            return(securitySettings ?? SecuritySetting.DefaultForUser(userId));
        }