Esempio n. 1
0
        private KerykeionDbResult KerykeionDbResultAfterTryCreateUser(IdentityResult result, TUser user)
        {
            if (result.Succeeded)
            {
                return(KerykeionDbResult.Success(user));
            }

            return(KerykeionDbResultFilledWithErrors(result.Errors));
        }
Esempio n. 2
0
        public async Task <KerykeionDbResult> AddLoginAsync(dynamic user, ExternalLoginInfo info)
        {
            IdentityResult result = await UserManager.AddLoginAsync(user, info);

            if (result.Succeeded)
            {
                return(KerykeionDbResult.Success(user));
            }

            return(KerykeionDbResultFilledWithErrors(result.Errors));
        }
Esempio n. 3
0
        public async Task <KerykeionDbResult> SetLanguageAsync(dynamic user, string language)
        {
            KerykeionUser thisUser = await UserManager.FindByIdAsync(user.Id.ToString());

            if (thisUser != null)
            {
                user.Language = Enum.Parse <KerykeionCmsLanguage>(language);
                IdentityResult result = await UserManager.UpdateAsync(user);

                if (result.Succeeded)
                {
                    return(KerykeionDbResult.Success());
                }
            }

            return(KerykeionDbResult.Fail());
        }
Esempio n. 4
0
        public async Task <KerykeionDbResult> AddProfileImage(dynamic user, IFormFile profileImage)
        {
            if (!(await GetUserProfileImageIncluded(user) is TUser currentUser))
            {
                return(KerykeionDbResult.Fail());
            }

            var errors = new List <KerykeionDbError>();

            if (currentUser.ProfileImage != null)
            {
                //var delImgResult = await EntitiesService.DeleteAsync(currentUser.ProfileImage, FolderConstants.UserProfileImagesFolderName);
                //if (!delImgResult.Successfull)
                //{
                //    return delImgResult;
                //}
            }

            if (await AddProfileImageToUserAndCheckCompletion(profileImage, currentUser))
            {
                var updateUserResult = await UserManager.UpdateAsync(currentUser);

                if (updateUserResult.Succeeded)
                {
                    return(KerykeionDbResult.Success());
                }
                foreach (var error in updateUserResult.Errors)
                {
                    errors.Add(new KerykeionDbError {
                        Message = error.Description
                    });
                }
            }

            errors.Add(new KerykeionDbError {
                Message = "Het uploaden van de afbeelding is mislukt."
            });
            return(KerykeionDbResult.Fail(errors.ToArray()));
        }