示例#1
0
        private async Task LoadUsersAndRoles()
        {
            try
            {
                var userList = await _userEndpoint.GetAll();

                Users = new BindingList <UserModel>(userList);
                var roles = await _userEndpoint.GetAllRoles();

                _allRoles = roles.Values.ToList();
            }
            catch (Exception ex)
            {
                dynamic settings = new ExpandoObject();
                settings.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                settings.ResizeMode            = ResizeMode.NoResize;
                settings.Title = "System Error";
                if (ex.Message.Equals("Unauthorized"))
                {
                    _status.UpdateMessage("Unauthorized Exception", "You do not have permission to interact with the sales form.");
                    await _window.ShowDialogAsync(_status, null, settings);
                }
                else
                {
                    _status.UpdateMessage("Fatal Exception", ex.Message);
                    await _window.ShowDialogAsync(_status, null, settings);
                }
                await TryCloseAsync();
            }
        }
        private async Task LoadRoles()
        {
            var roles = await _userEndpoint.GetAllRoles();

            foreach (var role in roles)
            {
                if (UserRoles.IndexOf(role.Value) < 0)
                {
                    AvailableRoles.Add(role.Value);
                }
            }
        }
        private async Task LoadRoles()
        {
            var roles = await _userEndpoint.GetAllRoles();

            foreach (var role in roles)
            {
                // We add to the available role list the given role if that is not in the selected roles's list.
                //if (SelectedUserRoles.Contains(role.Value) == false)
                if (UserRoles.IndexOf(role.Value) < 0)
                {
                    AvailableRoles.Add(role.Value);
                }
            }
        }
示例#4
0
        private async Task LoadAvailableRoles()
        {
            // call api to get all roles
            var roles = await _userEndpoint.GetAllRoles();

            foreach (var role in roles)
            {
                // check selected user role for existing roles, -1 is returned if the role is not asigned to current user
                if (SelectedUserRole.IndexOf(role.Value) < 0)
                {
                    // add those unasigned roles to the list of available roles
                    AvailableRoles.Add(role.Value);
                }
            }
        }
示例#5
0
        private async Task LoadRoles()
        {
            var roles = await _userEndpoint.GetAllRoles();

            _allRoles = roles.Select(x => x.Value).ToList();
        }