예제 #1
0
        public void JoinRoomTest()
        {
            CreateRoomTest();
            UserController user = new UserController();
            GuestJoin      join = new GuestJoin();

            join.Name   = "TESTINGUSER";
            join.RoomID = rooms[ran2.Next(0, rooms.Count - 1)].ToString();
            rooms.Remove(int.Parse(join.RoomID));
            string result = user.JoinRoom(join);

            string[] parts = result.Split('|');
            Assert.AreEqual(parts[3], join.RoomID);
        }
예제 #2
0
        public string JoinRoom([FromBody] GuestJoin info)
        {
            SqlConnection connection = new SqlConnection(connectionString);
            SqlCommand    command    = new SqlCommand("usp_addGuest", connection);

            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add(new SqlParameter("@Username", info.Name));
            command.Parameters.Add(new SqlParameter("@RoomID", info.RoomID));
            connection.Open();
            SqlDataAdapter adapter = new SqlDataAdapter(command);
            DataTable      table   = new DataTable();

            adapter.Fill(table);
            connection.Close();

            string username2 = table.Rows[0][0].ToString() + "|" + table.Rows[0][1].ToString() + "|" + table.Rows[0][2].ToString() + "|" + table.Rows[0][3].ToString() + "|" + table.Rows[0][4];

            return(username2);
        }