public static bool CanDelete(Authentication authentication, IUserDescriptor descriptor) { if (authentication.ID == descriptor.UserInfo.ID) { return(false); } return(authentication.Authority == Authority.Admin); }
public static bool CanSendMessage(Authentication authentication, IUserDescriptor descriptor) { if (authentication.ID == descriptor.UserInfo.ID) { return(false); } return(UserDescriptorUtility.IsOnline(authentication, descriptor)); }
public static async Task <bool> BanAsync(Authentication authentication, IUserDescriptor descriptor) { var dialog = await BanViewModel.CreateInstanceAsync(authentication, descriptor); if (dialog != null && await dialog.ShowDialogAsync() == true) { return(true); } return(false); }
public When_getting_history_entries() { _eventStore = A.Fake <IEventStore>(); _userDescriptor = A.Fake <IUserDescriptor>(); A.CallTo(() => _eventStore.Get(AggregateId)) .Returns(Task.FromResult(CreateTestEvents())); A.CallTo(() => _userDescriptor.GetUserDescription(UserId)) .Returns(User); }
internal void DisplayUserName(IUserDescriptor _UserDescriptor) { if (_UserDescriptor != null) { this.m_UserNameLiteral.Text = String.Format("Welcome {0} from {1} !", _UserDescriptor.User, _UserDescriptor.Company); } else { this.m_UserNameLiteral.Text = "Information about user is unavailable"; } }
public static bool IsOnline(Authentication authentication, IUserDescriptor descriptor) { if (authentication == null) { throw new ArgumentNullException(nameof(authentication)); } if (descriptor == null) { throw new ArgumentNullException(nameof(descriptor)); } return(descriptor.UserState.HasFlag(UserState.Online)); }
public static bool IsBanned(Authentication authentication, IUserDescriptor descriptor) { if (authentication == null) { throw new ArgumentNullException(nameof(authentication)); } if (descriptor == null) { throw new ArgumentNullException(nameof(descriptor)); } return(descriptor.BanInfo.ID != string.Empty); }
public static bool IsGuest(Authentication authentication, IUserDescriptor descriptor) { if (authentication == null) { throw new ArgumentNullException(nameof(authentication)); } if (descriptor == null) { throw new ArgumentNullException(nameof(descriptor)); } return(descriptor.UserInfo.Authority == Authority.Guest); }
public static bool CanUnban(Authentication authentication, IUserDescriptor descriptor) { if (authentication.ID == descriptor.UserInfo.ID) { return(false); } if (authentication.Authority != Authority.Admin) { return(false); } return(UserDescriptorUtility.IsBanned(authentication, descriptor) == true); }
public static bool CanKick(Authentication authentication, IUserDescriptor descriptor) { if (authentication == null) { return(false); } if (authentication.ID == descriptor.UserInfo.ID) { return(false); } if (authentication.Authority != Authority.Admin) { return(false); } return(UserDescriptorUtility.IsOnline(authentication, descriptor) == true); }
public static async Task <bool> UnbanAsync(Authentication authentication, IUserDescriptor descriptor) { if (descriptor.Target is IUser user) { try { await user.Dispatcher.InvokeAsync(() => user.Unban(authentication)); return(true); } catch (Exception e) { AppMessageBox.ShowError(e); return(false); } } else { throw new NotImplementedException(); } }
public override void SelectObject(object obj) { this.descriptor = obj as IUserDescriptor; if (this.descriptor != null) { foreach (var item in this.domains) { item.IsVisible = item.ContainsUser(this.descriptor.UserID); } this.DisplayName = $"{Resources.Title_UserDomainList} [{this.descriptor.UserID}]"; } else { foreach (var item in this.domains) { item.IsVisible = false; } this.DisplayName = Resources.Title_UserDomainList; } this.SelectedDomain = null; this.NotifyOfPropertyChange(nameof(this.IsVisible)); this.NotifyOfPropertyChange(nameof(this.SelectedObject)); }
public static Task <ChangeUserViewModel> CreateInstanceAsync(Authentication authentication, IUserDescriptor descriptor) { if (authentication == null) { throw new ArgumentNullException(nameof(authentication)); } if (descriptor == null) { throw new ArgumentNullException(nameof(descriptor)); } if (descriptor.Target is IUser user) { return(user.Dispatcher.InvokeAsync(() => { return new ChangeUserViewModel(authentication, user); })); } else { throw new ArgumentException("Invalid Target of Descriptor", nameof(descriptor)); } }
public override void SelectObject(object obj) { this.Detach(); this.descriptor = obj as IUserDescriptor; this.Attach(); }
public static async Task <bool> RenameAsync(Authentication authentication, IUserDescriptor descriptor) { return(await Task.Run(() => false)); }
public static async Task <bool> SendMessageAsync(Authentication authentication, IUserDescriptor descriptor) { if (descriptor.Target is IUser user) { var dialog = await SendMessageViewModel.CreateInstanceAsync(authentication, descriptor); return(dialog?.ShowDialog() == true); } else { throw new NotImplementedException(); } }
public static async Task <bool> BanAsync(Authentication authentication, IUserDescriptor descriptor) { var dialog = await BanViewModel.CreateInstanceAsync(authentication, descriptor); return(dialog?.ShowDialog() == true); }
public static Task <MoveUserViewModel> CreateInstanceAsync(Authentication authentication, IUserDescriptor descriptor) { if (authentication == null) { throw new ArgumentNullException(nameof(authentication)); } if (descriptor == null) { throw new ArgumentNullException(nameof(descriptor)); } if (descriptor.Target is IUser user) { return(user.Dispatcher.InvokeAsync(() => { var categories = user.GetService(typeof(IUserCategoryCollection)) as IUserCategoryCollection; var targetPaths = categories.Select(item => item.Path).ToArray(); return new MoveUserViewModel(authentication, user, targetPaths); })); } else { throw new ArgumentException("Invalid Target of Descriptor", nameof(descriptor)); } }
public static bool CanRename(Authentication authentication, IUserDescriptor descriptor) { return(false); }
public HistoryService(IEventStore eventStore, IUserDescriptor userDescriptor) { _eventStore = eventStore; _userDescriptor = userDescriptor; }
public static bool CanRename(Authentication _1, IUserDescriptor _2) { return(false); }
public UserDescriptor(Authentication authentication, IUserDescriptor descriptor, bool isSubscriptable, object owner) : base(authentication, descriptor.Target, descriptor, isSubscriptable) { this.user = descriptor.Target; this.Owner = owner ?? this; }
public static bool CanMove(Authentication authentication, IUserDescriptor _) { return(authentication.Authority == Authority.Admin); }
public static Task <SendMessageViewModel> CreateInstanceAsync(Authentication authentication, IUserDescriptor descriptor) { if (authentication == null) { throw new ArgumentNullException(nameof(authentication)); } if (descriptor == null) { throw new ArgumentNullException(nameof(descriptor)); } if (descriptor.Target is IUser user) { return(user.Dispatcher.InvokeAsync(() => { return new SendMessageViewModel(authentication, user); })); } else { throw new ArgumentException("ServiceProvider does not provide IUserContext", nameof(descriptor)); } }
public static bool CanChange(Authentication authentication, IUserDescriptor descriptor) { return(authentication.Authority == Authority.Admin); }