Beispiel #1
0
        public async Task UpdateUser(UserIdAndValue user)
        {
            try
            {
                var existingUser = await _userMgr.FindByIdAsync(user.Id);

                var userRoles = await _userMgr.GetRolesAsync(existingUser);

                if (user.Value == "on")
                {
                    var existingRole = userRoles.FirstOrDefault(d => d == user.Type);
                    if (existingRole == null)
                    {
                        userRoles.Insert(0, user.Type);
                    }
                }
                else
                {
                    var existingRole = userRoles.FirstOrDefault(d => d == user.Type);
                    if (existingRole != null)
                    {
                        userRoles.Remove(user.Type);
                    }
                }
                await _userMgr.UpdateAsync(existingUser);
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
                throw;
            }
        }
Beispiel #2
0
        public async Task UpdateUser(UserIdAndValue user)
        {
            try
            {
                var existingUser = await _userMgr.FindByIdAsync(user.Id);

                existingUser.JobTitle = user.Value;
                await _userMgr.UpdateAsync(existingUser);
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
                throw;
            }
        }