public async Task <IReadOnlyCollection <ChatParticipant> > Set(Guid chatId, IEnumerable <ChatUser> chatUsers, ChatParticipantType participantType, ChatParticipantStatus participantStatus, Guid setterId) { await Task.Yield(); return(chatUsers.Select(chatUser => SetUser(chatId, chatUser, participantType, participantStatus)).ToList()); }
public ChatParticipant(ChatParticipantType chatParticipantType, ChatParticipantStatus chatParticipantStatus, DateTime readTimestamp, long readIndex, long version, Guid userId, string name, string details, Guid?avatarId = null, bool inviteOnly = false, bool canCreateChat = true, string style = null, string metadata = null) : base(userId, name, details, avatarId, inviteOnly, canCreateChat, style, metadata) { ChatParticipantType = chatParticipantType; ChatParticipantStatus = chatParticipantStatus; ReadTimestamp = readTimestamp; ReadIndex = readIndex; Version = version; }
public async Task <ChatParticipant> Set(Guid chatId, ChatUser chatUser, ChatParticipantStatus participantStatus, Guid setterId) { await Task.Yield(); var participants = Store.Chats[chatId].Participants; lock (participants) { var exist = participants.FirstOrDefault(r => r.UserId == chatUser.UserId); if (exist == null) { exist = new ChatParticipant(ChatParticipantType.ReadOnlyParticipant, participantStatus, DateTime.MinValue, -1, 0, chatUser); participants.Add(exist); } else { exist.Version += 1; exist.ChatParticipantStatus = participantStatus; } return(exist); } }
private ChatParticipant SetUser(Guid chatId, ChatUser chatUser, ChatParticipantType participantType, ChatParticipantStatus participantStatus) { var participants = Store.Chats[chatId].Participants; lock (participants) { var exist = participants.FirstOrDefault(r => r.UserId == chatUser.UserId); if (exist == null) { exist = new ChatParticipant(participantType, participantStatus, DateTime.MinValue, -1, 0, chatUser); participants.Add(exist); } else { exist.Version += 1; exist.ChatParticipantType = participantType; exist.ChatParticipantStatus = participantStatus; } return(exist); } }
public async Task <ChatParticipant> Set(Guid chatId, ChatUser chatUser, ChatParticipantType participantType, ChatParticipantStatus participantStatus, Guid setterId) { await Task.Yield(); return(SetUser(chatId, chatUser, participantType, participantStatus)); }
public ChatParticipant(ChatParticipantType chatParticipantType, ChatParticipantStatus chatParticipantStatus, DateTime readTimestamp, long readIndex, long version, IChatUser user) : this(chatParticipantType, chatParticipantStatus, readTimestamp, readIndex, version, user.UserId, user.Name, user.Details, user.AvatarId, user.InviteOnly, user.CanCreateChat, user.Style, user.Metadata) { }
protected virtual Task <TChatParticipant> SetUser <TCommand>(TCommand command, ChatParticipantStatus participantStatus) where TCommand : IHasInitiator, IChatRelated, IUserRelated { return(SetUser(command.ChatId, command.UserId, participantStatus, command.InitiatorUserId)); }
protected virtual async Task <TChatParticipant> SetUser(Guid chatId, Guid userId, ChatParticipantStatus participantStatus, Guid setterId) { var user = await ReadUserStore.Retrieve(userId).ConfigureAwait(false); return(await ChatParticipantStore.Set(chatId, user, participantStatus, setterId).ConfigureAwait(false)); }
protected virtual Task <TChatParticipant> SetParticipationCandidate <TCommand>(TCommand command, ChatParticipantStatus participantStatus) where TCommand : IHasInitiator, IChatRelated, IParticipationCandidate { return(SetParticipationCandidate(command.ChatId, command.UserId, command.ChatParticipantType, participantStatus, command.Style, command.Metadata, command.InitiatorUserId)); }
protected virtual async Task <TChatParticipant> SetParticipationCandidate(Guid chatId, Guid userId, ChatParticipantType participantType, ChatParticipantStatus participantStatus, string style, string metadata, Guid setterId) { var user = await ReadUserStore.Retrieve(userId).ConfigureAwait(false); user = ReadUserStore.Customize(user, style, metadata); return(await ChatParticipantStore.Set(chatId, user, participantType, participantStatus, setterId).ConfigureAwait(false)); }