public async Task <Invite> GetByFriendAsync(int idFriendInvited) { using (var con = new SqlConnection(_configuration["ConnectionString"])) { var sqlCmd = @$ " SELECT Id, IdUsuario, IdUsuarioConvidado, Mensagem, Status_Convite From Convite Where IdusuarioConvidado='{idFriendInvited}';"; using (var cmd = new SqlCommand(sqlCmd, con)) { cmd.CommandType = CommandType.Text; con.Open(); var reader = await cmd .ExecuteReaderAsync() .ConfigureAwait(false); while (reader.Read()) { var invite = new Invite(int.Parse(reader["IdUsuario"].ToString()), int.Parse(reader["IdusuarioConvidado"].ToString()), reader["Mensagem"].ToString(), int.Parse(reader["Status_Convite"].ToString())); invite.SetId(int.Parse(reader["Id"].ToString())); return(invite); } return(default);