public Task <UserRegistery> RegisterUserAsync(string username) { if (Users.Any(user => user.Username.Equals(username, StringComparison.CurrentCulture))) { return(Task.FromResult((UserRegistery)null)); } var currentUser = new UserRegistery { Username = username, UserToken = Guid.NewGuid(), LastConnectionDate = DateTime.UtcNow }; Users.Add(currentUser); return(Task.FromResult(currentUser)); }
public async Task <bool> UpdateRoomRegisteryAsync(UserRegistery user, RoomRegistry roomData) { if (!Users.Any(r => r.Username.Equals(user.Username, StringComparison.Ordinal) && r.UserToken == user.UserToken)) { return(false); } if (!roomData.CreatedBy.Equals(user.Username)) { return(false); } await GrainFactory.GetGrain <IRoomGrain>(roomData.RoomName).SetupRoomAsync(roomData); return(true); }
public Task <bool> DeleteRoomAsync(UserRegistery user, string roomName) { if (!Users.Any(r => r.Username.Equals(user.Username, StringComparison.Ordinal) && r.UserToken == user.UserToken)) { return(Task.FromResult(false)); } var room = Rooms.SingleOrDefault(r => r.RoomName.Equals(roomName, StringComparison.Ordinal)); if (room == null) { return(Task.FromResult(false)); } room.IsDeleted = true; room.IsPubliclyVisible = false; return(Task.FromResult(true)); }
public Task MessageAsync(UserRegistery user, string message) { }