public CreateChatRoomRespond CreateChatRoom(CreateChatRoomRequest r) { _chatRoomRepository.Insert(new ChatRoom { NumOfMember = 2, ChatRoomName = r.User1Id + "and" + r.User2Id, CreatedAt = DateTime.Now }); ChatRoom i = _chatRoomRepository.GetChatRoomByName(r.User1Id + "and" + r.User2Id); _userChatRoomRepository.Insert(new UserChatRoom { ChatRoomId = i.Id, NickName = r.User1NickName, User = r.User1Id }); _userChatRoomRepository.Insert(new UserChatRoom { ChatRoomId = i.Id, NickName = r.User2NickName, User = r.User2Id }); i.ChatRoomName = r.User1NickName + " and " + r.User2NickName; _chatRoomRepository.Update(i); return(new CreateChatRoomRespond { RoomId = i.Id, RoomName = i.ChatRoomName, }); }