public void UserJoin(UserJoinViewModel model) { Users user = new Users() { Id = model.Id, Email = model.Email }; }
/// <summary> /// 加入会话 /// </summary> /// <param name="user"></param> /// <returns></returns> public async Task <JoinResult> Join(UserJoinViewModel user) { if (!user.IsValid()) { } user.ConnectionId = Context.ConnectionId; // 从在线会议室中获取此会议室 var onlineRoom = _onlineMeetingRoomManager.GetOne(user.SessionCode); // 从所有会议室获取到此会议室 var room = await _meetingRoomManager.GetBySessionCodeAsync(user.SessionCode); // 同时存在 if (onlineRoom == null || null == room) { return(new JoinResult(false, "找不到会话。请检查此代码是否正确,以及当前会话是否属于活动状态。")); } // 加入到此会议室中 var participant = _mapper.Map <UserJoinViewModel, Participant>(user); onlineRoom.Join(participant); _onlineMeetingRoomManager.AddOrUpdate(room.SessionCode, onlineRoom); await Groups.AddToGroupAsync(user.ConnectionId, onlineRoom.SessionCode); // 通知其他人有新用户加入 await Clients.GroupExcept(onlineRoom.SessionCode, user.ConnectionId).SendAsync("UserJoined", participant); // 添加加入会议的消息 var message = new Message(null, "System", $"{user.Nickname} 加入了会议", "zh-cn"); room.AppendMessage(message); await _meetingRoomManager.UpdateAsync(room); // 发送通知消息 var msg = _mapper.Map <Message, ReturnMessage>(message); await Clients.Group(onlineRoom.SessionCode).SendAsync("ReceiveMessage", msg); return(new JoinResult(true, "加入成功")); }
public ActionResult Join(UserJoinViewModel user) {
public ActionResult Join([Bind(Exclude = "USerId,Time,FreeSpace,TName")] JoinViewModel model, [Bind(Exclude = "Subscriptions,UserName,Password,FirstName,LastName,ConfirmPassword,BirthDate,PhoneNumber,IsEmailVerified,ActivationCode")] UserJoinViewModel umodel) { Treniruotes treniruotes = new Treniruotes() { Id = model.Id, UsersString = model.UsersString, Joins = model.Joins }; Users user = new Users() { Id = umodel.Id, Email = umodel.Email }; if (ModelState.IsValid) { treniruotes.Joins++; treniruotes.UsersString = treniruotes.UsersString + umodel.Id.ToString() + ","; db.Entry(treniruotes).State = EntityState.Modified; db.SaveChanges(); } return(View("Index")); }