Example #1
0
        public virtual async Task <IdentityUserDto> CreateAsync(IdentityUserCreateDto input)
        {
            try
            {
                await IdentityOptions.SetAsync();
            }
            catch (Exception e)
            {
                throw;
            }

            var user = new IdentityUser(
                GuidGenerator.Create(),
                input.UserName,
                input.Email,
                CurrentTenant.Id
                );

            input.MapExtraPropertiesTo(user);

            // TODO: this is another issue.
            // It throws an error without casting the type int to enum type before saving the user
            var      userType = user.GetProperty <int>("Type");
            UserType type     = (UserType)userType;

            user.SetProperty("Type", type);

            (await UserManager.CreateAsync(user, input.Password)).CheckErrors();
            await UpdateUserByInput(user, input);

            (await UserManager.UpdateAsync(user)).CheckErrors();

            await CurrentUnitOfWork.SaveChangesAsync();

            return(ObjectMapper.Map <IdentityUser, IdentityUserDto>(user));
        }