public async Task <IActionResult> PutChatroomMember(string id, ChatroomMember chatroomMember) { if (id != chatroomMember.ChatroomMemberId) { return(BadRequest()); } _context.Entry(chatroomMember).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ChatroomMemberExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <ChatroomMember> > PostChatroomMember(ChatroomMember chatroomMember) { _context.ChatroomMember.Add(chatroomMember); await _context.SaveChangesAsync(); return(CreatedAtAction("GetChatroomMember", new { id = chatroomMember.ChatroomMemberId }, chatroomMember)); }
public async Task <ActionResult <Chatroom> > PostChatroom(Chatroom chatroom) { _context.Chatroom.Add(chatroom); await _context.SaveChangesAsync(); chatroom.UniqueName = chatroom.Name.Replace(" ", "-"); ChatroomMember member = new ChatroomMember() { ChatroomId = chatroom.ChatroomId, DatalkUserId = chatroom.DatalkUserId, Type = ChatroomMemberType.Owner, }; _context.ChatroomMember.Add(member); await _context.SaveChangesAsync(); return(CreatedAtAction("GetChatroom", new { id = chatroom.ChatroomId }, chatroom)); }
static void Main(String[] args) { RongCloud rongCloud = RongCloud.GetInstance(appKey, appSecret); //自定义 api地址方式 //RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret,api); Chatroom chatroom = rongCloud.Chatroom; /** * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/chatroom/chatroom.html#create * * 创建聊天室 * * */ ChatroomModel[] chatrooms = { new ChatroomModel() { Id = "OIBbeKlkx", Name = "chatroomName1" }, new ChatroomModel() { Id = "chatroomId2", Name = "chatroomName2" } }; ResponseResult result = chatroom.Create(chatrooms); Console.WriteLine("create: " + result.ToString()); /** * * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/chatroom/chatroom.html#destory * 销毁聊天室 * * */ ChatroomModel chatroomModel = new ChatroomModel() { Id = "chatroomId2" }; //ResponseResult chatroomDestroyResult = chatroom.Destroy(chatroomModel); //Console.WriteLine("destroy: " + chatroomDestroyResult.ToString()); /** * * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/chatroom/chatroom.html#getMembers * 查询聊天室成员demo * * */ chatroomModel = new ChatroomModel() { Id = "OIBbeKlkx", Count = 10, Order = 1 }; ChatroomUserQueryResult chatroomQueryUserResult = chatroom.Get(chatroomModel); Console.WriteLine("queryUser: "******"e5ZnCtyfE", ChatroomId = "OIBbeKlkx" }; CheckChatRoomUserResult checkMemberResult = chatroom.IsExist(member); Console.WriteLine("checkChatroomUserResult: " + checkMemberResult.IsInChrm); Console.ReadLine(); }